﻿(function () {
    var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand;
    try {
        if (!!m) {
            m("BackgroundImageCache", false, true)
        }
    } catch (e) { };
})();
if (typeof (HTMLElement) != "undefined" && !window.opera && HTMLElement.prototype["__defineGetter__"]) {
    HTMLElement.prototype.__defineGetter__("canHaveChildren", function () {
        switch (this.tagName.toLowerCase()) {
            case "area": case "base": case "basefont":
            case "col": case "frame": case "hr":
            case "img": case "br": case "input":
            case "link": case "meta": case "isindex":
            case "param": return false;
        }
        return true;
    });
    HTMLElement.prototype.__defineGetter__("innerText", function () {
        return this.textContent;
    });
    HTMLElement.prototype.__defineSetter__("innerText", function (text) {
        this.textContent = text;
    });
    HTMLElement.prototype.__defineGetter__("className", function () {
        return this.getAttribute("class")
    });
    HTMLElement.prototype.__defineSetter__("className", function (className) {
        this.setAttribute("class", className)
    });
    HTMLElement.prototype.__defineGetter__("outerHTML", function () {
        var a = this.attributes, str = "<" + this.tagName, i = 0;
        for (; i < a.length; i++)
            if (a[i].specified) str += " " + a[i].name + '="' + a[i].value + '"';
        if (!this.canHaveChildren) return str + " />";
        return str + ">" + this.innerHTML + "</" + this.tagName + ">";
    });
    HTMLElement.prototype.__defineGetter__("children", function () {
        for (var a = [], j = 0, n, i = 0; i < this.childNodes.length; i++) {
            n = this.childNodes[i];
            if (n.nodeType == 1) {
                a.push(n);
                if (n.name) {
                    if (!a[n.name]) a[n.name] = [];
                    a[n.name].push(n);
                }
                if (n.id) a[n.id] = n;
            }
        }
        return a;
    });
    if (!HTMLElement.prototype.insertAdjacentHTML)
        HTMLElement.prototype.insertAdjacentHTML = function (where, html) {
            var e = this.ownerDocument.createRange();
            e.setStartBefore(this);
            e = e.createContextualFragment(html);
            switch (where) {
                case 'beforeBegin': this.parentNode.insertBefore(e, this); break;
                case 'afterBegin': this.insertBefore(e, this.firstChild); break;
                case 'beforeEnd': this.appendChild(e); break;
                case 'afterEnd':
                    if (!this.nextSibling) this.parentNode.appendChild(e);
                    else this.parentNode.insertBefore(e, this.nextSibling);
                    break;
            }
        };
    if (!HTMLElement.prototype.swapNode)
        HTMLElement.prototype.swapNode = function (node) {
            var nextSibling = this.nextSibling;
            var parentNode = this.parentNode;
            node.parentNode.replaceChild(this, node);
            parentNode.insertBefore(node, nextSibling);
        }
    if (!HTMLElement.prototype.removeNode)
        HTMLElement.prototype.removeNode = function (removeChild) {
            if (removeChild) this.innerHTML = "";
            var parentNode = this.parentNode;
            this.parentNode.removeChild(this);
        }
}

try {
    if (window.Event && Event.prototype["__defineSetter__"]) {
        Event.prototype.__defineSetter__("returnValue", function (b) {
            if (!b) this.preventDefault();
            return b;
        });
        Event.prototype.__defineSetter__("cancelBubble", function (b) {
            if (b) this.stopPropagation();
            return b;
        });
        Event.prototype.__defineGetter__("srcElement", function () {
            var node = this.target;
            while (node.nodeType != 1) node = node.parentNode;
            return node;
        });
        Event.prototype.__defineGetter__("fromElement", function () {
            var node;
            if (this.type == "mouseover")
                node = this.relatedTarget;
            else if (this.type == "mouseout")
                node = this.target;
            if (!node) return;
            while (node.nodeType != 1) node = node.parentNode;
            return node;
        });
        Event.prototype.__defineGetter__("toElement", function () {
            var node;
            if (this.type == "mouseout")
                node = this.relatedTarget;
            else if (this.type == "mouseover")
                node = this.target;
            if (!node) return;
            while (node.nodeType != 1) node = node.parentNode;
            return node;
        });
        Event.prototype.__defineGetter__("offsetX", function () {
            return this.layerX;
        });
        Event.prototype.__defineGetter__("offsetY", function () {
            return this.layerY;
        });
    }
} catch (e) { }
if (window.Node) {
    Node.prototype.replaceNode = function (Node) {
        this.parentNode.replaceChild(Node, this);
    }
    Node.prototype.removeNode = function (removeChildren) {
        if (removeChildren) this.innerHTML = "";
        var parentNode = this.parentNode;
        this.parentNode.removeChild(this);
    }
    Node.prototype.swapNode = function (Node) {
        var nextSibling = this.nextSibling;
        var parentNode = this.parentNode;
        node.parentNode.replaceChild(this, Node);
        parentNode.insertBefore(node, nextSibling);
    }
}
if (window.HTMLElement && HTMLElement.prototype["__defineGetter__"]) {
    HTMLElement.prototype.__defineGetter__("all", function () {
        var a = this.getElementsByTagName("*");
        var node = this;
        a.tags = function (sTagName) {
            return node.getElementsByTagName(sTagName);
        }
        return a;
    });
    HTMLElement.prototype.__defineGetter__("parentElement", function () {
        if (this.parentNode == this.ownerDocument) return null;
        return this.parentNode;
    });
    HTMLElement.prototype.__defineGetter__("children", function () {
        var tmp = [];
        var j = 0;
        var n;
        for (var i = 0; i < this.childNodes.length; i++) {
            n = this.childNodes[i];
            if (n.nodeType == 1) {
                tmp[j++] = n;
                if (n.name) {
                    if (!tmp[n.name])
                        tmp[n.name] = [];
                    tmp[n.name][tmp[n.name].length] = n;
                }
                if (n.id)
                    tmp[n.id] = n;
            }
        }
        return tmp;
    });
    HTMLElement.prototype.__defineGetter__("currentStyle", function () {
        return this.ownerDocument.defaultView.getComputedStyle(this, null);
    });
    HTMLElement.prototype.__defineSetter__("outerHTML", function (sHTML) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df = r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df, this);
        return sHTML;
    });
    HTMLElement.prototype.__defineGetter__("outerHTML", function () {
        var attr;
        var attrs = this.attributes;
        var str = "<" + this.tagName;
        for (var i = 0; i < attrs.length; i++) {
            attr = attrs[i];
            if (attr.specified)
                str += " " + attr.name + '="' + attr.value + '"';
        }
        if (!this.canHaveChildren)
            return str + ">";
        return str + ">" + this.innerHTML + "</" + this.tagName + ">";
    });
    HTMLElement.prototype.__defineGetter__("canHaveChildren", function () {
        switch (this.tagName.toLowerCase()) {
            case "area":
            case "base":
            case "basefont":
            case "col":
            case "frame":
            case "hr":
            case "img":
            case "br":
            case "input":
            case "isindex":
            case "link":
            case "meta":
            case "param":
                return false;
        }
        return true;
    });

    HTMLElement.prototype.__defineSetter__("innerText", function (sText) {
        this.textContent = sText;
    });
    HTMLElement.prototype.__defineGetter__("innerText", function () {
        return this.textContent;
    });
    HTMLElement.prototype.__defineSetter__("outerText", function (sText) {
        var parsedText = document.createTextNode(sText);
        this.outerHTML = parsedText;
        return parsedText;
    });
    HTMLElement.prototype.__defineGetter__("outerText", function () {
        var r = this.ownerDocument.createRange();
        r.selectNodeContents(this);
        return r.toString();
    });
    HTMLElement.prototype.attachEvent = function (sType, fHandler) {
        var shortTypeName = sType.replace(/on/, "");
        fHandler._ieEmuEventHandler = function (e) {
            window.event = e;
            return fHandler();
        }
        this.addEventListener(shortTypeName, fHandler._ieEmuEventHandler, false);
    }
    HTMLElement.prototype.detachEvent = function (sType, fHandler) {
        var shortTypeName = sType.replace(/on/, "");
        if (typeof (fHandler._ieEmuEventHandler) == "function")
            this.removeEventListener(shortTypeName, fHandler._ieEmuEventHandler, false);
        else
            this.removeEventListener(shortTypeName, fHandler, true);
    }
    HTMLElement.prototype.contains = function (Node) {
        do {
            if (Node == this) return true;
            Node = Node.parentNode;
        }
        while (Node);
        return false;
    }
    HTMLElement.prototype.insertAdjacentElement = function (where, parsedNode) {
        switch (where) {
            case "beforeBegin":
                this.parentNode.insertBefore(parsedNode, this);
                break;
            case "afterBegin":
                this.insertBefore(parsedNode, this.firstChild);
                break;
            case "beforeEnd":
                this.appendChild(parsedNode);
                break;
            case "afterEnd":
                if (this.nextSibling)
                    this.parentNode.insertBefore(parsedNode, this.nextSibling);
                else
                    this.parentNode.appendChild(parsedNode);
                break;
        }
    }
    HTMLElement.prototype.insertAdjacentHTML = function (where, htmlStr) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML = r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where, parsedHTML);
    }
    HTMLElement.prototype.insertAdjacentText = function (where, txtStr) {
        var parsedText = document.createTextNode(txtStr);
        this.insertAdjacentElement(where, parsedText);
    }
    HTMLElement.prototype.attachEvent = function (sType, fHandler) {
        var shortTypeName = sType.replace(/on/, "");
        fHandler._ieEmuEventHandler = function (e) {
            window.event = e;
            return fHandler();
        }
        this.addEventListener(shortTypeName, fHandler._ieEmuEventHandler, false);
    }
    HTMLElement.prototype.detachEvent = function (sType, fHandler) {
        var shortTypeName = sType.replace(/on/, "");
        if (typeof (fHandler._ieEmuEventHandler) == "function")
            this.removeEventListener(shortTypeName, fHandler._ieEmuEventHandler, false);
        else
            this.removeEventListener(shortTypeName, fHandler, true);
    }
}
if (window.HTMLTableElement && window.HTMLTableElement["prototype.__defineGetter__"]) {
    HTMLTableElement.prototype.__defineGetter__("cells", function () {
        var reCells = [];
        var rows = this.rows;
        for (var i = 0, count = rows.length; i < count; i++) {
            var cells = rows[i].cells;
            for (var j = 0, len = cells.length; j < len; j++) {
                reCells.push(cells[j]);
            }
        }
        return reCells;
    });
}

//**********************
//  本JS框架可独立存在
//  使用了$vs,vs,vsClass三个变量,若引入使用了这些全局变量的JS框架或代码,将会同本框架代码相冲突
//  作者:张大为
//  $vs下的变量及方法,都是静态变量及方法,vs下挂Class类型定义,vsClass用于对类型进行局部缩略化
//**********************
if(typeof($vs) == "undefined"){
    var $vs = window.$vs = {};
}else{
    throw new Error("$vs框架加载失败或重复加载!");
}
if(typeof(vs) == "undefined"){
    var vs = window.vs = {};
    vs.dom = {};
}else{
    throw new Error("vs框架加载失败或重复加载!");
}
if(typeof(vsClass) == "undefined")var vsClass = window.vsClass = {};

$vs.dom = {};
$vs.server = {};
$vs.response = {};
$vs.browser = {isIE:(document.all != null)}; 
$vs.pager = {};
$vs.doc = {};
$vs.parser = {};
$vs.request = {};
$vs.designMode = !String;
$vs.timerStep = {stepNow:0,step:1000};
$vs.timerStep.NextStep = function(){var stepNew = this.stepNow;this.stepNow += this.step;}

$vs.request.Runer = function(){
    var search = document.location.search;
    if(search == "" || search == "?")return;
    if (search && search.substr(0, 1) == "?") search = search.substr(1);
    var arr = search.split("&");
    for(var i=0,count = arr.length;i<count;i++){
        var paramArr = arr[i].split("=");var n = paramArr[0];var v = paramArr[1];
        if(n == "Runer")continue;
        this[n] = (this[n] == null)
            ?v:((this[n].constructor == Array)
                ?this[n].concat([v]):[this[n],v]);
    }
};if(!$vs.designMode)$vs.request.Runer();

$vs.config = {isDebug:true,rootPath:"/",isOneDesktop:false}

if(Date.prototype.format == null)Date.prototype.format = function(format){
    ///<summary>格式化日期值</summary>
    ///<param name="format">支持yyyy-MM-dd HH:mm:ss或一半的格式替换符</param>
    ///<returns type="String"></returns>
    var regs = [/yyyy/g,/MM/g,/dd/g,/HH/g,/mm/g,/ss/g];
    var regs2 = [/yy/g,/M/g,/d/g,/H/g,/m/g,/s/g];
    var values = [this.getFullYear(),this.getMonth() + 1, this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()];
    for(var i = 0;i<6;i++){
        format = format.replace(regs[i],(values[i] > 9)?values[i]:"0" + values[i]);
        format = format.replace(regs2[i],values[i]);
    }
    return format;
}
if(Date.ParseEnyFormat == null)Date.ParseEnyFormat = function(dateString){
    ///<summary>任意数字日期时间字符串的解析，解析失败就返回null</summary>
    ///<param name="dateString">要格式化的日期字符串</param>
    var parseReg = /[^0-9]+/g;
    var arr = (""+dateString).split(parseReg);
    var len = arr.length;
    if(!(len == 3 || len >= 5))return null;
    var yearPos = -1;
    for(var i=0;i<len;i++){if(parseInt(arr[i],10) > 31){yearPos = i;break;}}
    var date;
    if(yearPos == -1 && len == 3){//只有时间
        date = new Date();
        date.setHours(parseInt(arr[0],10),parseInt(arr[1],10),parseInt(arr[2],10));
        return date;
    }else if((yearPos == 0 || yearPos == 2)){
        date = new Date();
        if(yearPos == 0){
            date.setFullYear(parseInt(arr[0],10),parseInt(arr[1],10) - 1,parseInt(arr[2],10));
        }else{
            date.setFullYear(parseInt(arr[2],10),parseInt(arr[0],10) - 1,parseInt(arr[1],10));
        }
        if(len >= 5){
            var hours = parseInt(Object.isNull(arr[3],0),10);
            if(hours > 100){
                date.setHours(0,0,0,0);
            }else{
                date.setHours(hours,parseInt(Object.isNull(arr[4],0),10),
                parseInt(Object.isNull(arr[5],0),10),
                parseInt(Object.isNull(arr[6],0),10));
            }
        }else{
            date.setHours(0,0,0,0);
        }
        return date;
    }else{
        return null;
    }
}

if(String.format == null)String.format = function(string,args){
    ///<summary>格式化字符串<summary>
    ///<param name="string">包含{num}替换符的字符串</param>
    ///<param name="args">要替换的值参数</param>
    ///<returns type="String"></returns>
    var reg,val;
    for(var i=0,count = arguments.length - 1;i<count;i++){
        reg = new RegExp("[\{]{1}"+i+"[\}]{1}","g");
        val = arguments[i + 1];
        if(val == null)break;
        string = string.replace(reg,val);
    }
    return string;
}
if(String.prototype.trim == null)String.prototype.trim = function() {
    /// <summary locid="M:J#String.trim" />
    /// <returns type="String"></returns>
    return this.replace(/^\s+|\s+$/g, '');
}
if(String.prototype.trimEnd == null)String.prototype.trimEnd = function() {
    /// <summary locid="M:J#String.trimEnd" />
    /// <returns type="String"></returns>
    return this.replace(/\s+$/, '');
}
if(String.prototype.trimStart == null)String.prototype.trimStart = function() {
    /// <summary locid="M:J#String.trimStart" />
    /// <returns type="String"></returns>
    return this.replace(/^\s+/, '');
}

Number.prototype.formatZero = function(zero){
    ///<summary>用零符占位</summary>
    ///<param name="zero">零占位符</param>
    ///<returns type="String"></returns>
    var arr = zero.split(".");
    var str = ""+this;
    var next = str.split(".");
    var need = ["0000000000000000000000000000000000","00000000000000000000000000000000"];
    next[0] = (arr[0].length > next[0].length)?need[0].substr(0,arr[0].length - next[0].length) + next[0]:next[0];
    if(arr.length > 1) next[1] = (arr[1].length > next[1].length)?need[1].substr(0,arr[1].length - next[1].length) + next[1]:next[1];
    return next.join(".");
}
Object.isLinkAvoid = function(val){
/// <summary>验证变量是否已经退出内存或引用不存在</summary>
/// <param name="val">要验证的变量</param>
    try{var a = val.constructor;}catch(e){return true;}
    return false;
}
Object.isNull = function(value,replace){
/// <summary>null值变换</summary>
/// <param name="value">要进行判定的值</param>
	return (replace == null)?(value == null):((value == null)?replace:value);
}
Object.isNullOrEmpty = function(obj,value){
/// <summary>null值或空值变换</summary>
/// <param name="value">要进行判定的值，不传值，将返回obj是否为空或null</param>
	return (value == null)?(obj == null || (typeof(obj) == "number" && isNaN(obj)) || obj === ""):((obj == null || (typeof(obj) == "number" && isNaN(obj)) || obj === "")?value:obj);
}
$vs.inherit = function(thisRef,args,baseType){
/// <summary>内部直接继承</summary>
/// <param name="thisRef">直接写this</param>
/// <param name="args">直接写arguments</param>
/// <param name="baseType">要继承的类型</param>
/// <returns type="vs.baseType.Type"></returns>
	var q = args[0];
	if(q == null)q = {};
	baseType.apply(thisRef,[q]);
	return q;
}
$vs.initType = function (typeRef) {
	/// <summary>初始化指定类型的信息</summary>
	/// <param name="typeRef">类型的引用，默认为window.Class属性当前值</param>
	typeRef = (typeRef == null) ? window.Class : typeRef;
	var object = new typeRef();
	if (typeRef.Private1 && typeRef.Private1.TypeName == "vs.Pager") {
		if (document.VSPageLoadComplete) window.setTimeout(object.Load, 0)
		else document.OnVSPageLoad.push(object.Load);
	} else {
		try { typeRef.Type(); } catch (e) { }
		typeRef.Demo = new typeRef();
		vs.baseType = typeRef;
		typeRef.New = function () {
			var obj = new this();
			obj.Init.apply(obj, arguments);
			delete (obj.Init); //去掉Init方法,防止破坏封装体
			return obj;
		}
	}
}
$vs.addEvent = function(sender,ev){
/// <summary>为某实例新增事件</summary>
/// <param name="sender">事件实例</param>
/// <param name="ev">事件名</param>
	if(sender["On" + ev])return;
	sender["On" + ev] = [];
	sender["On" + ev + "_End"] = [];
	sender[ev] = function(){
		var evs = sender["On" + ev];
		var goOn;
		for(var i=0,evCount = evs.length;i<evCount;){
			if(Object.isLinkAvoid(evs[i]) || typeof(evs[i]) == "undefined"){
				evs.splice(i,1);
				evCount--;
				continue;
			}
			goOn = evs[i].apply(sender,arguments);
            
			if(goOn === false){
				sender[ev + "_End"].apply(sender,arguments);
				return false;
			}
			i++;
		}
		sender[ev + "_End"].apply(sender,arguments);
		return true;
	}
	sender[ev + "_End"] = function(){
		var evs = sender["On" + ev + "_End"];
		var goOn;
		for(var i=0,evCount = evs.length;i<evCount;){
			if(Object.isLinkAvoid(evs[i]) || typeof(evs[i]) == "undefined"){
				evs.splice(i,1);
				evCount--;
				continue;
			}
			goOn = evs[i].apply(sender,arguments);
			if(goOn === false){
				return false;
			}
			i++;
		}
		return true;
	}
}
$vs.addEvent(document,"VSPageLoad");
//if(document.attachEvent)document.attachEvent("onreadystatechange",function(){
//    if(document.readyState == "complete")document.VSPageLoad();
//});
//if(document.addEventListener)document.addEventListener("readystatechange",function(){
//    alert(document.readyState);
//    if(document.readyState == "complete")document.VSPageLoad();
//},false);
$vs.browser.getWindow = function(element) {
    var doc = element.ownerDocument || element.document || element;
    return doc.defaultView || doc.parentWindow;
}
$vs.addHandler = function(element, eventName, handler){
/// <summary>对事件添加处理程序</summary>
/// <param name="element">节点</param>
/// <param name="eventName">事件名,如"click"</param>
/// <return type="handler">响应方法</return>
    if (!element._events)  element._events = {};
    var eventCache = element._events[eventName];
    if (!eventCache) {
        element._events[eventName] = eventCache = [];
    }
    var browserHandler;
    if(element.attachEvent){
        browserHandler = function(){
            var e = {};
            try{e = $vs.browser.getWindow(this).event;}catch(ex){}
            return handler.call(element, e);
        }
        element.attachEvent("on"+eventName,browserHandler);
    }else if(element.addEventListener){
        browserHandler = function(e) {
            return handler.call(element, e);
        }
        element.addEventListener(eventName,browserHandler, false);
    }
    eventCache[eventCache.length] = {handler: handler, browserHandler: browserHandler}
}
$vs.removeHandler = function(element,eventName,handler){
/// <summary>对事件移除指定处理程序</summary>
/// <param name="element">节点</param>
/// <param name="eventName">事件名,如"click"</param>
/// <return type="handler">响应方法</return>
    var cache = element._events[eventName];
    var browserHandler;
    if (!(cache instanceof Array)) throw new Error("未通过 $vs.addHandler 方法添加处理程序");
    for (var i = 0, l = cache.length; i < l; i++) {
        if (cache[i].handler === handler) {
            browserHandler = cache[i].browserHandler;
            break;
        }
    }
    if (element.removeEventListener) {
        element.removeEventListener(eventName, browserHandler, false);
    }
    else if (element.detachEvent) {
        element.detachEvent('on' + eventName, browserHandler);
    }
    cache.splice(i, 1);
}
$vs.clearHandlers = function(element) {
/// <summary>移除所有处理程序</summary>
/// <param name="element">节点</param>
    if (element._events) {
        var cache = element._events;
        for (var name in cache) {
            var handlers = cache[name];
            for (var i = handlers.length - 1; i >= 0; i--) {
                $vs.removeHandler(element, name, handlers[i].handler);
            }
        }
        element._events = null;
    }
}
$vs.addHandler(window,"load",function(){
    window.setTimeout(function(){document.VSPageLoad();document.VSPageLoadComplete = true;},0);
});

//$vs.exceptionParse = function(ex){
///// <summary>根据是否是调试状态将请求异常格式化为文本</summary>
///// <param name="ex">要进行转化的异常对象</param>
//    return $vs.config.isDebug?(ex.get_message() + "<br />程序调用堆栈:<hr />" 
//        + ex.get_stackTrace().replace(/\r\n/g,"<br />")):ex.get_message();
//}

$vs.response.write = function(exOrMsg,viewElement){
/// <summary>将指定消息和异常输出到指定节点中，若节点为null，则返回转换后的消息</summary>
/// <param name="exOrMsg">要进行转化的异常对象</param>
/// <param name="viewElement">要进行转化的异常对象</param>
/// <return type="String">返回转换后输出的消息内容</return>
	var html = exOrMsg;
	if(typeof(exOrMsg) == "object" && exOrMsg.get_message != null){
		html = $vs.exceptionParse(exOrMsg);
	}
	if(viewElement == null) return html;
	var view = document.createElement("Li");
	view.innerHTML = html;
	view.style.display = "block";
	view.style.borderBottom = "1px solid gray";
	view.AutoClear = function(){
	    window.setTimeout(function(){
	        try{this.removeNode(true);}catch(e){};
	    },10000);
	}
	viewElement.appendChild(view);
	view.AutoClear();
	viewElement.ondblclick = function(){
		this.innerHTML = "";
	}
	return html;
}
$vs.server.mapPath = function(rootTagPath){
/// <summary>根路径的值在登录页面设置</summary>
/// <param name="rootTagPath">以~代表根路径的路径</param>
	return rootTagPath.replace(new RegExp("^~\\/")
	    ,$vs.config.rootPath);
}
if(!window.vsXMLHttpRequest)window.vsXMLHttpRequest=function(){
    var b=["Mxsml2.XMLHTTP.3.0","Msxml2.XMLHTTP"];
    for(var a=0,c=b.length;a<c;a++)try{return new ActiveXObject(b[a])}catch(d){}
    return null
};
$vs.browser.xmlHttp = null;
$vs.browser.getData = function(path,exHandler){
/// <summary>读取指定路径的HTTP返回文本</summary>
/// <param name="path">以~代表根路径的路径</param>
/// <param name="exHandler">路径无法访问时的处理函式，参数(msg)</param>
	path = $vs.server.mapPath(path);
	if(xmlHttp == null)xmlHttp = new window.vsXMLHttpRequest();
	try{
		xmlHttp.open("get",path,false);
		xmlHttp.setRequestHeader('If-Modified-Since', '0');
		xmlHttp.send(null);
	}catch(e){return null;}
	var status = xmlHttp.status;
	if(status != "200"){
		if(status == 304 || status == 400){	
			//客户端有缓冲的文档并发出了一个条件性的请求
			//（一般是提供If-Modified-Since头表示客户只想比指定日期更新的文档）。
			//服务器告诉客户，原来缓冲的文档还可以继续使用。
			return null;
		}
		var errorMsg = path+String.format("\r\n无法正常访问,错误代号{0}:具体错误如下:\r\n========================\r\n",xmlHttp.status) + xmlHttp.responseText;
		if(exHandler)exHandler(errorMsg);
		return null;
	}
	var text = xmlHttp.responseText;
	return text;
}
$vs.browser.getDataObject = function(jsPath){
/// <summary>读取指定JS数据对象</summary>
/// <param name="jsPath">以~代表根路径的路径</param>
	var js = $vs.browser.getData(jsPath,function(msg){if(window.MasterPage)window.MasterPage.SetStatus(msg);});
	try{return window.eval("(" + js + ")");}catch(e){return null;}
}
$vs.parser.parserOne = function(obj){
	var text = "",tag = "";
	for(prop in obj){
		if(typeof(obj[prop]) == "function")continue;
		var value = (""+obj[prop]).replace("'","\\'");
		text += tag + prop + "=" + ((obj[prop].constructor == Array) ? "['"+value + "']" : "'"+value+"'");
		tag = "\/";
	}
	text = text.replace(new RegExp(",","g"),"','");text = text.replace(new RegExp("\/","g"),",");
	text = "{" + text + "}";
	return text;
}
$vs.parser.view = function(obj,Document){
	var div = (Document || document).createElement("DIV");
	div.innerHTML = this.parserOne(obj);
	(Document || document).body.appendChild(div);
}
vsClass = vs.Object = function(){
    var q = arguments[0];
    if(q == null)q = {};
    
    var Me = this;
    var Static = q.Static = this.constructor;
    if(Static.Private == null){
        Static.Private = new function(){
            var S = this;
            var uniqueIndex = 0;
            S.NewObject = function(){
				var index = uniqueIndex;
				uniqueIndex++;
				return index;
            }
            S.Demos = {};
        }
        Static.Q = q;
        Static.Inited = true;
        q.Type = Static.Type = function(){
            for(var prop in Me){
                if(prop == "Init")continue;
                Static.Type.prototype[prop] = Me[prop];
            }
        }
    }
    Me.Bind = q.Bind = {};
    Me.UniqueIndex = q.UniqueIndex = Static.Private.NewObject(Me);
    q.Config = {}; q.Info = {};q.State = {}; q.Inits = {}; 
    q.Handlers = {}; q.Events = {}; q.Acts = {}; q.Enums = {};
    q.Controls = {}; Me.Demos = q.Demos = Static.Private.Demos;
    Me.Nodes = q.Nodes = {};
    
    q.a__Attribute0 = function(){
    }
    Me.Init = q.Init = function(){
        AttachEvent();
    }
    var AttachEvent = q.AttachEvent = function(){
    }
    
    q.Destroy = function(){
		for(prop in q){
			delete(q[prop]);
		}
		for(prop in Me){
			delete(Me[prop]);
		}
		if(CollectGarbage){
			CollectGarbage();
　　　　	window.setTimeout("try{CollectGarbage();}catch(e){}", 1);
　　　　}
    }
};$vs.initType(vsClass);
vsClass.$new = function(){
    /// <returns type="vs.Object.Type"></returns>
    return this.New.apply(this,arguments);
}

vsClass = vs.Pager = function(){
    var q = $vs.inherit(this,arguments,vs.Object);
    if(!q.Static.Private1){
        q.Static.Private1 = new function(){
            var S = this;
            S.TypeName = "vs.Pager";
            S.$ = function(id){
            ///<summary>按ID查找标签</summary>
            ///<returns type="$vs.dom.Node.Type"/>
            return document.getElementById(id);
            };
            S.$name = function(name){
            ///<summary>按name查找标签组</summary>
            ///<returns type="Array"/>
                return document.getElementsByName(name);
            };
            S.$tagName = function(tagName){
            ///<summary>按标签名查找标签组</summary>
            ///<returns type="Array"/>
            return document.getElementsByTagName(tagName);
            };
        }
    }
    this.Load = q.Load = function(){}
    
    q.$ = q.Static.Private1.$;
    q.$name = q.Static.Private1.$name;
    q.$tagName = q.Static.Private1.$tagName;
    
};$vs.initType(vsClass);
vsClass.$new = function(){
    /// <returns type="vs.Pager.Type"></returns>
    return this.New.apply(this,arguments);
}
with($vs){
    dom.A = dom.Button = dom.CheckInput = dom.Div = dom.Fieldset = dom.Form = dom.HR = dom.Iframe = dom.Image 
    = dom.ImageInput
    = dom.Input = dom.Label = dom.Legend = dom.Marquee = dom.Node = dom.Option = dom.P = dom.Pre = dom.Select 
    = dom.Span = dom.Style = dom.Table = dom.TBody = dom.TD = dom.Textarea = dom.TFood = dom.THead = dom.TR = {style:{},
        EnumAlign : {center:"center",justify:"justify",left:"left",right:"right",Default:"left"},
        EnumNodeType : {Element:1,Text:3},
        EnumReadyState : {uninitialized:"uninitialized",loading:"loading"
            ,loaded:"loaded",interactive:"interactive",complete:"complete"},
        EnumTarget : {Blank:"_blank",Self:"_self",Parent:"_parent",Default:""},
        EnumApplyElementPosition : {Outside:"outside",Inside:"inside"}};
    dom.DoNothingHref = "javascript:void(0);";
}
with($vs){
    doc.$get = function(id){return document.getElementById(id);}
    with(doc){
        doc.GetNode = doc.GetDiv = doc.GetFieldSet = doc.GetLegend
         = doc.GetP = doc.GetHR = doc.GetPre = doc.GetSpan = function(id){
         ///<returns type="$vs.dom.Node.Type"></returns>
	        return $get(id);
        }
        doc.GetA = doc.GetALink = function(id){
        ///<returns type="$vs.dom.A.Type"></returns>
	        return $get(id);
        }
        doc.GetForm = function(id){
	        ///<returns type="$vs.dom.Form.Type"></returns>
	        return $get(id);
        }
        doc.GetIframe = function(id){
	        ///<returns type="$vs.dom.Iframe.Type"></returns>
	        return $get(id);
        }
        doc.GetImage = function(id){
	        ///<returns type="$vs.dom.Image.Type"></returns>
	        return $get(id);
        }
        doc.GetMarquee = function(id){
	        ///<returns type="$vs.dom.Marquee.Type"></returns>
	        return $get(id);
        }
        doc.GetOption = function(id){
	        ///<returns type="$vs.dom.Option.Type"></returns>
	        return $get(id);
        }
        doc.GetSelect = function(id){
	        ///<returns type="$vs.dom.Select.Type"></returns>
	        return $get(id);
        }
        doc.GetTable = function(id){
	        ///<returns type="$vs.dom.Table.Type"></returns>
	        return $get(id);
        }
        doc.GetTBody = function(id){
	        ///<returns type="$vs.dom.TBody.Type"></returns>
	        return $get(id);
        }
        doc.GetTR = function(id){
	        ///<returns type="$vs.dom.TR.Type"></returns>
	        return $get(id);
        }
        doc.GetTD = function(id){
	        ///<returns type="$vs.dom.TD.Type"></returns>
	        return $get(id);
        }
        doc.GetButton = function(id){
	        ///<returns type="$vs.dom.Button.Type"></returns>
	        return $get(id);
        }
        doc.GetLabel = function(id){
	        ///<returns type="$vs.dom.Label.Type"></returns>
	        return $get(id);
        }
        doc.GetCheckBoxInput = doc.GetRadioInput = doc.GetCheckInput = function(id){
	        ///<returns type="$vs.dom.CheckInput.Type"></returns>
	        return $get(id);
        }
        doc.GetFileInput = function(id){
	        ///<returns type="$vs.dom.FileInput.Type"></returns>
	        return $get(id);
        }
        doc.GetHiddenInput = doc.GetInput = doc.GetPasswordInput = doc.GetResetInput
         = doc.GetSubmitInput = doc.GetTextInput = function(id){
	        ///<returns type="$vs.dom.Input.Type"></returns>
	        return $get(id);
        }
        doc.GetImageInput = function(id){
	        ///<returns type="$vs.dom.ImageInput.Type"></returns>
	        return $get(id);
        }
    }
}
//==================
with($vs){
    dom.Blank = "&nbsp;";
    dom.NewA = dom.NewALink = function(href,target,innerHTML,isInlineBlock){
	    ///<returns type="$vs.dom.A.Type"></returns>
	    var link = document.createElement("A");
	    if(!String)link = dom.A;
	    link.href = Object.isNullOrEmpty(href,"javascript:void(0)");
	    link.target = Object.isNull(target,"");
	    link.innerHTML = Object.isNull(innerHTML,"");
	    if(isInlineBlock == true)link.style.display = "inline-block";
	    return link;
    }
    dom.NewDiv = function(innerHTML){
	    ///<param name="innerHTML">默认为nbsp;</param>
	    ///<returns type="$vs.dom.Node.Type"></returns>
	    var div = document.createElement("DIV");
	    if(!String)div = dom.Node;
	    div.innerHTML = Object.isNull(innerHTML,"");
	    return div;
    }
    dom.NewHR = function(){
	    ///<param name="innerHTML">默认为nbsp;</param>
	    ///<returns type="$vs.dom.Node.Type"></returns>
	    var hr = document.createElement("HR");
	    return hr;
    }
    dom.NewFieldset = function(title){
	    ///<returns type="$vs.dom.Node.Type"></returns>
	    var fieldset = document.createElement("FIELDSET");
	    if(title != null){
		    var legend = document.createElement("LEGEND");
		    legend.innerHTML = title;
		    fieldset.appendChild(legend);
	    }
	    return fieldset;
    }
    dom.NewForm = function(action,method,formEncoding){
	    ///<returns type="$vs.dom.Form.Type"></returns>
	    var form = document.createElement("FORM");
	    if(!String)form = dom.Form;
	    form.action = Object.isNull(action,"");
	    form.method = Object.isNullOrEmpty(method,dom.Form.EnumMethod.Get);
	    form.encoding = Object.isNull(formEncoding,dom.Form.EnumFormEncoding.Default);
	    return form;
    }
    dom.BlankUrl = "about:blank";
    dom.NewIframe = function (src, name) {
    	///<returns type="$vs.dom.Iframe.Type"></returns>
    	name = Object.isNullOrEmpty(name, "");
    	var iframe = null;
    	if ($vs.browser.isIE) {
    		try { iframe = document.createElement(String.format("<iframe id='{0}' name='{0}'></iframe>", name)); } catch (e) { }
    	} 
		if(iframe == null){
    		iframe = document.createElement("IFRAME");
    	}
    	if (!String) iframe = dom.Iframe;
    	if (src != null) iframe.src = src;
    	iframe.id = name;
    	iframe.name = name;
    	return iframe;
    }
    dom.NewImage = dom.NewImg = function(src){
	    ///<returns type="$vs.dom.Image.Type"></returns>
	    var image = new Image();
	    if(src != null){
    //		if(src.toUpperCase().indexOf(".PNG") > 0 && Sys.Browser.InternetExplorer){
    //			//PNG图片透明处理
    //		}
		    image.src = src;
	    }
	    return image;
    }
    dom.NewLegend = function(title){
	    ///<returns type="$vs.dom.Node.Type"></returns>
	    var legend = document.createElement("LEGEND");
	    legend.innerHTML = Object.isNullOrEmpty(title,"");
	    return legend;
    }
    dom.NewMarquee = function(){
	    ///<returns type="$vs.dom.Marquee.Type"></returns>
	    var marquee = document.createElement("Marquee");
	    return marquee;
    }
    dom.NewOption = function(text,value){
	    ///<returns type="$vs.dom.Option.Type"></returns>
	    var option = document.createElement("option");
	    option.innerHTML = text;
	    option.value = Object.isNull(value,text);
	    return option;
    }
    dom.NewP = function(innerHTML){
	    ///<returns type="$vs.dom.Node.Type"></returns>
	    var p = document.createElement("P");
	    p.innerHTML = Object.isNull(innerHTML,"");
	    return p;
    }
    dom.NewPre = function(innerHTML){
	    ///<returns type="$vs.dom.Node.Type"></returns>
	    var pre = document.createElement("PRE");
	    pre.innerHTML = Object.isNull(innerHTML,"");
	    return pre;
    }
    dom.NewSelect = function(isMulti){
	    ///<returns type="$vs.dom.Select.Type"></returns>
	    var select = document.createElement("SELECT");
	    if(!String)select = dom.Select;
	    select.multiple = isMulti;
	    return select;
    }
    dom.NewSpan = function(innerHTML,isInlineBlock){
	    ///<returns type="$vs.dom.Node.Type"></returns>
	    var span = document.createElement("SPAN");
	    if(isInlineBlock == true)span.style.display = "inline-block";
	    span.innerHTML = Object.isNull(innerHTML,"");
	    return span;
    }
    dom.NewUL = function(){
	    /// <returns type="$vs.dom.Node.Type"></returns>
	    var ul = document.createElement("UL");
	    return ul;
    }
    dom.NewOL = function(){
	    /// <returns type="$vs.dom.Node.Type"></returns>
	    var ol = document.createElement("OL");
	    return ol;
    }
    dom.NewLI = function(innerHTML){
	    /// <returns type="$vs.dom.Node.Type"></returns>
	    var li = document.createElement("LI");
	    li.innerHTML = Object.isNull(innerHTML,"");
	    return li;
    }
    dom.NewTable = function(){
	    ///<returns type="$vs.dom.Table.Type"></returns>
	    var table = document.createElement("table");
	    if(!String)table = dom.Table;
	    table.border = 0;
	    table.cellPadding = 0;
	    table.cellSpacing = 0;
	    return table;
    }
    dom.NewTBody = function(table){
	    ///<returns type="$vs.dom.TBody.Type"></returns>
	    var tbody = document.createElement("TBody");
	    if(table)table.appendChild(tbody);
	    return tbody;
    }
    dom.NewTHead = function(table){
	    ///<returns type="$vs.dom.THead.Type"></returns>
	    var thead = document.createElement("THead");
	    if(table)table.appendChild(thead);
	    return thead;
    }
    dom.NewTFoot = function(table){
	    ///<returns type="$vs.dom.TFoot.Type"></returns>
	    var tfoot = document.createElement("TFoot");
	    if(table)table.appendChild(tfoot);
	    return tfoot;
    }
    dom.NewTR = dom.NewRowOfTable = function(tableOrTBody,rowIndex){
	    ///<returns type="$vs.dom.TR.Type"></returns>
	    if(!String)tableOrTBody = dom.TBody;
	    var tr = tableOrTBody.insertRow(Object.isNull(rowIndex,-1));
	    return tr;
    }
    dom.NewTD = dom.NewCellOfTable = function(tr,cellIndex,text){
	    ///<returns type="$vs.dom.TD.Type"></returns>
	    if(!String)tr = dom.TR;
	    var td = tr.insertCell(Object.isNull(cellIndex,-1));
	    td.innerHTML = Object.isNull(text,"");
	    return td;
    }
    dom.NewTH = dom.NewHeadCellOfTable = function(tr,cellIndex,text){
	    ///<returns type="$vs.dom.TD.Type"></returns>
	    if(!String)tr = dom.TR;
	    var th = document.createElement("TH");
	    th.innerHTML = Object.isNull(text,"");
	    var td = tr.insertCell(Object.isNull(cellIndex,-1));
	    tr.replaceChild(th,td);
	    return th;
    }
    //===============
    dom.NewButton = function(innerHTML){
	    ///<returns type="$vs.dom.Button.Type"></returns>
	    var button = document.createElement("Button");
	    button.innerHTML = Object.isNull(innerHTML,"");
	    return button;
    }
    //===============
    dom.NewLabel = function(text,htmlFor){
	    ///<returns type="$vs.dom.Label.Type"></returns>
	    var label = document.createElement("Label");
	    if(!String)label = dom.Label;
	    label.innerHTML = text;
	    label.htmlFor = htmlFor;
	    return label;
    }
    dom.NewCheckBoxInput = function (name, value) {
    	///<returns type="$vs.dom.CheckInput.Type"></returns>
    	var checkbox = null;
    	if ($vs.browser.isIE) {
    		try { checkbox = document.createElement(String.format("<input type='checkbox' name='{0}' />", name)); } catch (e) { }
    	} 
		if(checkbox == null) {
    		checkbox = document.createElement("input");
    		checkbox.type = "checkbox";
    		checkbox.name = name;
    	}
    	if (!String) checkbox = dom.CheckInput;
    	checkbox.value = Object.isNull(value, "");
    	checkbox.id = dom.CheckInput.Static.NewID();
    	return checkbox;
    }
    dom.NewRadioInput = function (name, value) {
    	///<returns type="$vs.dom.CheckInput.Type"></returns>
    	var radio = null;
    	if ($vs.browser.isIE) {
    		try {
    			radio = document.createElement(String.format("<input type='radio' name='{0}' />", name));
    		} catch (e) { }
    	} 
		if(radio == null){
    		radio = document.createElement("input");
    		radio.type = "radio";
    		radio.name = name;
    	}
    	if (!String) radio = dom.CheckInput;
    	radio.value = Object.isNull(value, "");
    	radio.id = dom.CheckInput.Static.NewID();
    	return radio;
    }
    dom.NewFileInput = function (idAndname, value) {
    	///<returns type="$vs.dom.Input.Type"></returns>
    	var input = null;
    	if ($vs.browser.isIE) {
    		try { input = document.createElement(String.format("<input type='file' id='{0}' name='{0}' />", idAndname)); } catch (e) { }
    	} 
		if(input == null){
    		input = document.createElement("input");
    		input.type = "file";
    		input.name = idAndname;
    		input.id = idAndname;
    	}
    	if (!String) input = dom.Input;
    	input.value = Object.isNull(value, "");
    	return input;
    }
    dom.NewButtonInput = function (idAndname, value) {
    	///<returns type="$vs.dom.Input.Type"></returns>
    	var input = null;
    	if ($vs.browser.isIE) {
    		try { input = document.createElement(String.format("<input type='button' id='{0}' name='{0}' />", idAndname)); } catch (e) { }
    	} 
		if(input == null) {
    		input = document.createElement("input");
    		input.type = "button";
    		input.name = idAndname;
    		input.id = idAndname;
    	}
    	if (!String) input = dom.Input;
    	input.value = Object.isNull(value, "");
    	return input;
    }
    dom.NewHiddenInput = function (idAndname, value) {
    	///<returns type="$vs.dom.Input.Type"></returns>
    	var input = null;
    	if ($vs.browser.isIE) {
    		try { input = document.createElement(String.format("<input type='hidden' id='{0}' name='{0}' />", idAndname)); } catch (e) { }
    	} 
		if(input == null){
    		input = document.createElement("input");
    		input.type = "hidden";
    		input.name = idAndname;
    		input.id = idAndname;
    	}
    	input.value = Object.isNull(value, "");
    	return input;
    }
    dom.NewImageInput = function (idAndname, value, src) {
    	///<returns type="$vs.dom.ImageInput.Type"></returns>
    	var image = null;
    	if ($vs.browser.isIE) {
    		try { image = document.createElement(String.format("<input type='image' id='{0}' name='{0}' />", idAndname)); } catch (e) { }
    	} 
		if(image == null){
    		image = document.createElement("input");
    		image.type = "image";
    		image.name = idAndname;
    		image.id = idAndname;
    	}
    	if (!String) image = dom.ImageInput;
    	image.value = Object.isNull(value, "");
    	image.src = src;
    	return image;
    }
    dom.NewPasswordInput = function (idAndname, value) {
    	///<returns type="$vs.dom.Input.Type"></returns>
    	var input = null;
    	if ($vs.browser.isIE) {
    		try { input = document.createElement(String.format("<input type='password' id='{0}' name='{0}' />", idAndname)); } catch (e) { }
    	} 
		if(input == null) {
    		input = document.createElement("input");
    		input.type = "password";
    		input.name = idAndname;
    		input.id = idAndname;
    	}
    	input.value = Object.isNull(value, "");
    	return input;
    }
    dom.NewResetInput = function (idAndname, value) {
    	///<returns type="$vs.dom.Input.Type"></returns>
    	var input = null;
    	if ($vs.browser.isIE) {
    		try { input = document.createElement(String.format("<input type='reset' id='{0}' name='{0}' />", idAndname)); } catch (e) { }
    	} 
		if(input == null) {
    		input = document.createElement("input");
    		input.type = "reset";
    		input.name = idAndname;
    		input.id = idAndname;
    	}
    	input.value = Object.isNull(value, "");
    	return input;
    }
    dom.NewSubmitInput = function (idAndname, value) {
    	///<returns type="$vs.dom.Input.Type"></returns>
    	var input = null;
    	if ($vs.browser.isIE) {
    		try { input = document.createElement(String.format("<input type='submit' id='{0}' name='{0}' />", idAndname)); } catch (e) { }
    	} 
		if(input == null) {
    		input = document.createElement("input");
    		input.type = "submit";
    		input.name = idAndname;
    		input.id = idAndname;
    	}
    	input.value = Object.isNull(value, "");
    	return input;
    }
    dom.NewSubmitInputWithValue = function (value) {
    	///<returns type="$vs.dom.Input.Type"></returns>
    	var input = null;
    	if ($vs.browser.isIE) {
    		try { input = document.createElement("<input type='submit' />"); } catch (e) { }
    	}
    	if (input == null) {
    		input = document.createElement("input");
    		input.type = "submit";
    	}
    	input.value = Object.isNull(value, "");
    	return input;
    }
	dom.NewTextInput = function (idAndname, value) {
	    ///<returns type="$vs.dom.Input.Type"></returns>
	    var input = null;
	    if($vs.browser.isIE){
		    try{input = document.createElement(String.format("<input type='text' id='{0}' name='{0}' />",idAndname));}catch(e){}
	    }
		if(input == null){
		    input = document.createElement("input");
		    input.type = "text";
		    input.name = idAndname;
		    input.id = idAndname;
	    }
	    input.value = Object.isNull(value,"");
	    return input;
    }
    dom.NewTextarea = function(idAndname,value){
	    ///<returns type="$vs.dom.Input.Type"></returns>
	    var textarea;
	    textarea = document.createElement("textarea");
	    textarea.name = idAndname;
	    textarea.id = idAndname;
	    textarea.value = Object.isNull(value,"");
	    return textarea;
    }
    dom.Events = ["onabort","onafterprint","onafterupdate"
    ,"onbeforecopy","onbeforecut","onbeforeeditfocus"
    ,"onbeforepaste","onbeforeprint","onbeforeunload"
    ,"onbeforeupdate","onblur","onbounce"
    ,"oncellchange","onchange","onclick"
    ,"oncontextmenu","oncopy","oncut"
    ,"ondataavailable","ondatasetchanged","ondatasetcomplete"
    ,"ondblclick","ondrag","ondragend"
    ,"ondragenter","ondragleave","ondragover"
    ,"ondragstart","ondrop","onerror"
    ,"onerrorupdate","onfilterchange","onfinish"
    ,"onfocus","onhelp","onkeydown"
    ,"onkeypress","onkeyup","onload"
    ,"onlosecapture","onmousedown","onmousemove"
    ,"onmouseout","onmouseover","onmouseup"
    ,"onpaste","onpropertychange","onreadystatechange"
    ,"onreset","onresize","onrowenter"
    ,"onrowexit","onrowsdelete","onrowsinserted"
    ,"onscroll","onselect","onselectstart"
    ,"onstart","onstop","onsubmit"
    ,"onunload"]
    for(var domEventIndex = 0,domEventCount = dom.Events.length;domEventIndex<domEventCount;domEventIndex++){
        var eventName = dom.Events[domEventIndex];
        dom.Events[eventName] = eventName.substring(2);
    }
}

/// <reference path="dom.js" />

vsClass = vs.Control = function(){with($vs){
    var q = $vs.inherit(this,arguments,vs.Object);
    if(!String)q=vs.Object.Q;
    
    var Static = q.Static;
    if (Static && Static.Private1 == null) {
        Static.Private1 = new function(){
			var S = this;
			var StringWidthTestInited = false;
			var StringWidthTestCase = dom.Node;
			var StringWidthTestNode = dom.Node;
			S.GetStringWidth = function(str){
				if(!StringWidthTestInited){
					StringWidthTestCase = dom.NewDiv();
					StringWidthTestNode = dom.NewSpan("",true);
					document.body.appendChild(StringWidthTestCase);
					StringWidthTestCase.appendChild(StringWidthTestNode);
					StringWidthTestInited =  true;
				}
				StringWidthTestCase.style.display = "block";
				StringWidthTestNode.innerHTML = str;
				var width = parseInt(StringWidthTestNode.offsetWidth);
				StringWidthTestCase.style.display = "none";
				return width;
			}
        }
    }
    if(q.Nodes) q.Nodes.MainCase = dom.Node;
    
    q.AddClass = vs.Control.AddClass = function(el,className){
        var oldClassName = el.className;
        if(Object.isNullOrEmpty(oldClassName) == true)
			el.className = className;
        else if((" "+oldClassName + " ").indexOf(" "+className + " ") == -1) 
			el.className += " " + className;
		
    }
    
    q.BindSkin = function(typeName){
        var className;
        var arr;
        q.AddClass(q.Nodes.MainCase,typeName);
        for(var prop in q.Nodes){
			var nodes = q.Nodes[prop];
			if(nodes && nodes.nodeType == dom.Node.EnumNodeType.Element){
				className = prop;
                q.AddClass(nodes,className);
			}
			if(nodes && nodes.constructor == Array){
				arr = nodes;
				for(var i=0,count = arr.length;i<count;i++){
					if(arr[i]  && arr[i].nodeType == dom.Node.EnumNodeType.Element){
						className = prop + "_" + i;
						q.AddClass(arr[i],prop);
						q.AddClass(arr[i],className);
					}
				}
			}
        }
    }
    
    q.BindSelfSkin = function(typeName){
        var className;
        var arr;
        q.AddClass(q.Nodes.MainCase,typeName);
        var cssHeader = typeName + "_";
        for(var prop in q.Nodes){
			var nodes = q.Nodes[prop];
			if(nodes && nodes.nodeType == dom.Node.EnumNodeType.Element){
				className = cssHeader+prop;
                q.AddClass(nodes,className);
			}
			if(nodes && nodes.constructor == Array){
				arr = nodes;
				for(var i=0,count = arr.length;i<count;i++){
					if(arr[i]  && arr[i].nodeType == dom.Node.EnumNodeType.Element){
						className = cssHeader+prop + "_" + i;
						q.AddClass(arr[i],cssHeader+prop);
						q.AddClass(arr[i],className);
					}
				}
			}
        }
    }
    q.GetPointerX = function(event){
        return event.pageX||(event.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));
    }
    q.GetPointerY = function(event){
        return event.pageY||(event.clientY+(document.documentElement.scrollTop||document.body.scrollTop));
    }
}};$vs.initType(vsClass);

vsClass.$new = function(){
    ///<returns type="vs.Control.Type"></returns>
    return this.New.apply(this,arguments);
}

/// <reference path="vs_common.js" />
/// <reference path="dom.js" />
vsClass = vs.MoveHand = function () {
    with ($vs) {
        var q = $vs.inherit(this, arguments, vs.Control);
        if (!String) q = vs.Control.Q;

        var Static = q.Static;
        if (Static.Private2 == null) {
            Static.Private2 = new function () {
                var S = this;
                var ContentHeightLimit = 1024;
                S.KeepResize = function (contentHeight) {
                    ContentHeightLimit = contentHeight;
                }
                S.GetContentHeightLimit = function () { return ContentHeightLimit; }
            }
        }
        var Me = this;
        $vs.addEvent(Me, "Started"); //开始,参数无
        $vs.addEvent(Me, "Moved"); //偏移,参数(x,y),分别为X,Y方向上的偏移量
        $vs.addEvent(Me, "MoveError"); //偏移出错,参数无
        $vs.addEvent(Me, "Stoped"); //结束,参数无

        q.Nodes.Pane = dom.Node;
        q.Nodes.PaneCenter = dom.Node;
        q.Nodes.MainCase = q.Nodes.CaseView = dom.Node;
        q.Nodes.ContentView = dom.Node;
        q.Nodes.DownHand = dom.Node;

        q.MoveingActNow = "";
        q.PaneBorderWidth = 4;
        q.MoveGroup = { Up: dom.Node, Right: dom.Node, Down: dom.Node, Left: dom.Node
		, RightUp: dom.Node, RightDown: dom.Node, LeftDown: dom.Node, LeftUp: dom.Node
        };
        q.MoveArrayList = ["Up", "Right", "Down", "Left", "RightUp", "RightDown", "LeftDown", "LeftUp"];
        q.MoveCursorArray = ["n", "e", "s", "w", "ne", "se", "sw", "nw"];
        q.MoveActArray = ["th", "w", "h", "lw", "thw", "wh", "hlw", "lwth"];
        q.MinHeight = 100;
        q.MinWidth = 200;
        q.Draging = false;
        q.DragPos = {
            x: -1,
            y: -1,
            StartWidth: 0,
            StartHeight: 0
        };
        q.BackPos = {
            x: -1,
            y: -1
        }

        q.GetPointerX = function (event) {
            var re = event.pageX || (event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
            return re;
        }
        q.GetPointerY = function (event) {
            var re = event.pageY || (event.clientY + (document.documentElement.scrollTop || document.body.scrollTop));
            return re;
        }
        var baseInit = q.Init;
        q.Init = function () {
            if (arguments.callee.Runed === true) return; arguments.callee.Runed = true;
            baseInit();
            q.Nodes.Pane = dom.NewDiv();
            q.Nodes.PaneCenter = dom.NewDiv();
            q.Nodes.CaseView.insertBefore(q.Nodes.Pane, q.Nodes.CaseView.firstChild);
            q.Nodes.Pane.appendChild(q.Nodes.PaneCenter);
            with (q.Nodes.PaneCenter.style) {
                filter = "alpha(opacity=20)";
                opacity = 0;
            }
            q.BindSelfSkin("vs_MoveHand");
        }
        Me.Load = q.Load = function (caseView, contentView, upNode, rightNode, downNode, leftNode, rightUpNode, rightDownNode, leftDownNode, leftUpNode) {
            q.Nodes.MainCase = q.Nodes.CaseView = caseView;
            q.Nodes.ContentView = contentView;

            q.Init();
            q.MoveGroup = { Up: upNode, Right: rightNode, Down: downNode, Left: leftNode
			, RightUp: rightUpNode, RightDown: rightDownNode, LeftDown: leftDownNode, LeftUp: leftUpNode
            };
            //		q.MoveArrayList = [upNode,rightNode,leftNode
            //			,rightUpNode,rightDownNode,leftDownNode,leftUpNode];
            //		q.Nodes.DownHand = downNode;
            //		q.MoveArrayList = [q.MoveGroup.Up,q.MoveGroup.Right,q.MoveGroup.Down,q.MoveGroup.Left
            //			,q.MoveGroup.RightUp,q.MoveGroup.RightDown,q.MoveGroup.LeftDown,q.MoveGroup.LeftUp];
            AttachEvent()
        }
        q.ReturnFalse = function () { return false; }
        q.StartMove = function (event) {
            q.Draging = true;
            var node = this;
            q.MoveingActNow = q.MoveActArray[node.vs_MoveHand_TypeIndex];
            $vs.addHandler(document, "mousemove", q.Moving);
            $vs.addHandler(document, "mouseup", q.StopMove);
            $vs.addHandler(document, "selectstart", q.ReturnFalse);
            var mouseX = q.GetPointerX(event);
            var mouseY = q.GetPointerY(event);
            q.Nodes.ContentView.firstChild.style.display = "none";
            with (q.DragPos) {
                x = mouseX;
                y = mouseY;
                StartWidth = (parseInt(q.Nodes.CaseView.offsetWidth) - q.PaneBorderWidth * 2);
                StartHeight = (parseInt(q.Nodes.CaseView.offsetHeight) - q.PaneBorderWidth * 2);
            }
            q.Nodes.ContentView.firstChild.style.display = "block";
            q.Nodes.Pane.style.display = "block";
            q.Nodes.Pane.style.top = "0px"; //parseInt(q.Nodes.CaseView.style.top) + "px";
            q.Nodes.Pane.style.left = "0px"; //parseInt(q.Nodes.CaseView.style.left) + "px";
            q.Nodes.Pane.style.width = q.DragPos.StartWidth + "px";
            q.Nodes.Pane.style.height = q.DragPos.StartHeight + "px";
            Me.Started();
        }
        q.Moving = function (event) {
            if (!q.Draging) return;
            var mouseX = q.GetPointerX(event);
            var mouseY = q.GetPointerY(event);
            var moveAct = q.MoveingActNow.toUpperCase();
            var moveX = mouseX - q.DragPos.x;
            var moveY = mouseY - q.DragPos.y;
            var cancelL = false;
            var cancelT = false;
            if (moveAct.indexOf("W") != -1) {
                var width = parseInt(q.Nodes.Pane.style.width) + ((moveAct.indexOf("L") == -1) ? 1 : -1) * moveX;
                if (width >= q.MinWidth) {
                    q.Nodes.Pane.style.width = width + "px";
                } else {
                    cancelL = true;
                }
            }
            if (moveAct.indexOf("H") != -1) {
                var height = parseInt(q.Nodes.Pane.style.height) + ((moveAct.indexOf("T") == -1) ? 1 : -1) * moveY;
                if (height >= q.MinHeight &&
				(parseInt(q.Nodes.CaseView.style.top) + parseInt(q.Nodes.Pane.style.top) + height + q.PaneBorderWidth * 2 <= vs.MoveHand.Private2.GetContentHeightLimit())) {
                    q.Nodes.Pane.style.height = height + "px";
                } else {
                    cancelT = true;
                }
            }
            if (!cancelL && moveAct.indexOf("L") != -1) {
                q.Nodes.Pane.style.left = parseInt(q.Nodes.Pane.style.left) + moveX + "px";
            }
            if (!cancelT && moveAct.indexOf("T") != -1) {
                q.Nodes.Pane.style.top = parseInt(q.Nodes.Pane.style.top) + moveY + "px"
            }
            if (!cancelL) {
                q.DragPos.x = mouseX;
            }
            if (!cancelT) {
                q.DragPos.y = mouseY;
            }
            Me.Moved(moveX, moveY);
        }
        q.StopMove = function (event) {
            if (!q.Draging) return;
            q.Draging = false;
            $vs.removeHandler(document, "mousemove", q.Moving);
            $vs.removeHandler(document, "mouseup", q.StopMove);
            $vs.removeHandler(document, "selectstart", q.ReturnFalse);
            var mouseX = q.GetPointerX(event) - (document.documentElement.scrollLeft || document.body.scrollLeft);
            var mouseY = q.GetPointerY(event) - (document.documentElement.scrollTop || document.body.scrollTop);
            q.Nodes.Pane.style.display = "none";
            if (mouseX < 1 || mouseY < 1 || mouseX > document.body.clientWidth || mouseY > document.body.clientHeight) {
                Me.MoveError();
            } else {
                var top = parseInt(q.Nodes.CaseView.style.top) + parseInt(q.Nodes.Pane.style.top);
                var left = parseInt(q.Nodes.CaseView.style.left) + parseInt(q.Nodes.Pane.style.left);
                var width = parseInt(q.Nodes.ContentView.style.width) + parseInt(q.Nodes.Pane.style.width) - q.DragPos.StartWidth;
                var height = parseInt(q.Nodes.ContentView.style.height) + parseInt(q.Nodes.Pane.style.height) - q.DragPos.StartHeight;
                //q.Nodes.ContentView.innerHTML = parseInt(q.Nodes.ContentView.style.height) +"|"+ parseInt(q.Nodes.Pane.style.height) +"|"+ q.DragPos.StartHeight + "|"+height;
                if (top > 0) q.Nodes.CaseView.style.top = top + "px";
                if (left > 0) q.Nodes.CaseView.style.left = left + "px";
                //q.Nodes.ContentView.innerHTML = parseInt(q.Nodes.ContentView.style.width) +"|"+ parseInt(q.Nodes.Pane.style.width) +"|"+ q.DragPos.StartWidth;
                if (width > 0) q.Nodes.ContentView.style.width = width + "px";
                if (height > 0) q.Nodes.ContentView.style.height = height + "px";
                window.status = (11);
                Me.Stoped();
                window.status = (12);
            }
            q.Nodes.ContentView.focus();
        }
        Me.HideAll = q.HideAll = function () {
            for (var i = 0, count = q.MoveArrayList.length; i < count; i++) {
                var node = q.MoveGroup[q.MoveArrayList[i]];
                if (node == null) continue;
                node.style.visibility = "hidden";
            }
        }
        Me.ShowAll = q.ShowAll = function () {
            for (var i = 0, count = q.MoveArrayList.length; i < count; i++) {
                var node = q.MoveGroup[q.MoveArrayList[i]];
                if (node == null) continue;
                node.style.visibility = "visible";
            }
        }
        var AttachEvent = function () {
            for (var i = 0, count = q.MoveArrayList.length; i < count; i++) {
                var node = q.MoveGroup[q.MoveArrayList[i]];
                if (node == null) continue;
                var cursor = q.MoveCursorArray[i] + "-resize";
                node.style.cursor = cursor;
                node.vs_MoveHand_TypeIndex = i;
                $vs.addHandler(node, "mousedown", q.StartMove);
            }
            //		if(q.DownHand != null){
            //			q.Nodes.DownHand.style.cursor = q.MoveCursorArray[i] + "-resize";
            //			q.Nodes.DownHand.vs_MoveHand_TypeIndex = i;
            //			$vs.addHandler(q.DownHand,"mousedown",q.StartMove);
            //		}
        }
    } 
}
$vs.initType(vsClass);

vsClass.$new = function () {
    ///<returns type="vs.MoveHand.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="vs.Control.js" />

vsClass = vs.Layer = function () {
    with ($vs) {
        var q = $vs.inherit(this, arguments, vs.Control);
        if (!String) q = vs.Control.Q;

        var Static = q.Static;
        if (Static.Private2 == null) {
            if (window.vs11 && vs11.UI.Layer) {
                Static.Private2 = vs11.UI.Layer.Private_vs_UI_Layer;
            } else {
                Static.Private2 = new function () {
                    var S = this;
                    var LAYER_BASE = 600;
                    var LAYER_KEEP_TOP_BASE = 60000;
                    var LAYER_STEP = 5;
                    var KeepTopLayerIndexNow = LAYER_KEEP_TOP_BASE;
                    var LayerZIndexNow = LAYER_BASE;
                    var LayerArray = [];
                    $vs.addEvent(S, "Actived")	//激活某一层,参数(layer)
                    S.NewLayer = function (layer) {
                        ///<returns type="Number"></returns>
                        var layerZIndex = LayerZIndexNow;
                        LayerZIndexNow += LAYER_STEP;
                        LayerArray.push(layer);
                        return layerZIndex;
                    }
                    S.NewTopLayer = function (layer) {
                        var layerZIndex = KeepTopLayerIndexNow;
                        KeepTopLayerIndexNow += LAYER_STEP;
                        return layerZIndex;
                    }
                    S.SetActived = function (layerMe) {
                        if (layerMe.GetIsModal()) return;
                        var myZIndex = layerMe.GetZIndex();
                        for (var i = 0, count = LayerArray.length; i < count; i++) {
                            var layer = LayerArray[i];
                            var layerZIndex = layer.GetZIndex();
                            if (layerZIndex == myZIndex) {
                                layer.SetZIndex(LayerZIndexNow - LAYER_STEP);
                            } else if (layerZIndex > myZIndex) {
                                layer.SetZIndex(layerZIndex - LAYER_STEP);
                            }
                        }
                        S.Actived(layerMe);
                    }
                    S.DeleteLayer = function (layerMe) {
                        var myZIndex = layerMe.GetZIndex();
                        for (var i = 0, count = LayerArray.length; i < count; i++) {
                            var layer = LayerArray[i];
                            var layerZIndex = layer.GetZIndex();
                            if (layerZIndex == myZIndex) {
                                LayerArray.splice(i, 1);
                                break;
                            }
                        }
                    }
                }
            }
        }
        var Me = this;
        $vs.addEvent(Me, "ToStartMove");
        q.Draging = false;
        q.IsModal = false;
        q.ZIndex = -1;
        q.MainCaseAt = dom.Node;

        q.Nodes.MainCase = dom.Node;
        q.Nodes.ModalLayer = dom.Node;
        q.Nodes.ModalFrame = dom.Iframe;
        q.Nodes.CoverFrame = dom.Iframe;

        q.LastPos = { Left: "inherit", Top: "inherit", OffsetWidth: 0, OffsetHeight: 0, Width: 0, Height: 0 };

        q.DragPos = {
            x: -1,
            y: -1
        };
        q.BackPos = {
            x: -1,
            y: -1
        }

        Me.GetZIndex = q.GetZIndex = function () {
            return q.ZIndex;
        }
        Me.GetIsShow = function () {
            return (q.Nodes.MainCase.style.display == "block");
        }
        Me.GetIsModal = function () { return q.IsModal; }
        Me.SetZIndex = q.SetZIndex = function (zIndex) {
            q.ZIndex = zIndex;
            q.Nodes.MainCase.style.zIndex = zIndex + 2; //q.Nodes.MainCase.style.border="1px solid red";
            q.Nodes.ModalLayer.style.zIndex = zIndex; //q.Nodes.ModalLayer.style.border="1px solid red";
        }
        q.SetLayer = function () {
            with (q.Nodes.MainCase.style) {
                zIndex = q.ZIndex + 2;
                display = "none";
            }
            with (q.Nodes.CoverFrame) {
                frameBorder = 0;
                //			src = "about:blank";
                with (style) {
                    width = (q.Nodes.MainCase.offsetWidth) + "px";
                    filter = "alpha(opacity=20)";
                    opacity = 0.01;
                    height = q.Nodes.MainCase.offsetHeight + "px";
                }
            }
        }
        q.ReSetLayer = function () {
            with (q.Nodes.CoverFrame) {
                with (style) {
                    width = (q.Nodes.MainCase.offsetWidth) + "px";
                    height = q.Nodes.MainCase.offsetHeight + "px";
                }
            }
        }
        q.Acts.ShowXY = function (posX, posY) {
            q.Nodes.MainCase.style.display = "block";
        }
        q.Acts.Show = function () {
            q.Nodes.MainCase.style.display = "block";
            q.ReSetLayer();
        }
        q.Acts.Hide = function () {
            q.Nodes.MainCase.style.display = "none";
        }

        q.SetModal = function () {
            with (q.Nodes.ModalLayer.style) {
                zIndex = q.ZIndex;
                filter = "alpha(opacity=20)";
                opacity = 0.2;
                display = "none";
            }
            //q.Nodes.ModalLayer.style["-moz-opacity"] = 0.2;
            with (q.Nodes.ModalFrame) {
                frameBorder = 0;
                //			src = "about:blank";
            }
        }
        var baseInit = q.Init;
        Me.Init = q.Init = function (isModal, mainCaseAt) {
            if (arguments.callee.Runed === true) return; arguments.callee.Runed = true;
            if (q.ZIndex == -1) q.ZIndex = vs.Layer.Private2.NewLayer(Me);
            baseInit();
            q.IsModal = (isModal === true) ? true : false;
            q.Nodes.MainCase = dom.NewSpan("", true);
            q.MainCaseAt = (mainCaseAt == null)
		    ? document.getElementsByTagName("form")[0] || document.body
		    : mainCaseAt;
            with (q.Nodes.MainCase.style) {
                left = "";
                top = "";
            }
            if (q.IsModal) {
                q.Nodes.ModalFrame = dom.NewIframe();
                q.Nodes.ModalLayer = dom.NewDiv();
                q.AddClass(q.Nodes.ModalLayer, "vs_Layer_ModalLayer");
                q.AddClass(q.Nodes.ModalFrame, "vs_Layer_ModalFrame");
                document.body.appendChild(q.Nodes.ModalLayer);
                q.Nodes.ModalLayer.appendChild(q.Nodes.ModalFrame);
            }
            q.Nodes.CoverFrame = dom.NewIframe();
            q.MainCaseAt.appendChild(q.Nodes.MainCase);
            q.Nodes.MainCase.appendChild(q.Nodes.CoverFrame);
            q.SetLayer();
            q.SetModal();
            q.BindSelfSkin("vs_Layer");
            q.AddClass(q.Nodes.MainCase, "vs_Layer_MainCase")
            AttachEvent();
        }
        q.ReturnFalse = function () { return false; }
        q.StartMove = function (event) {
            if (!Me.ToStartMove(Me)) return;
            q.Draging = true;
            $vs.addHandler(document, "mousemove", q.Moving);
            $vs.addHandler(document, "mouseup", q.StopMove);
            $vs.addHandler(document, "selectstart", q.ReturnFalse);
            var mouseX = q.GetPointerX(event);
            var mouseY = q.GetPointerY(event);
            var leftMe = parseInt(q.Nodes.MainCase.style.left);
            var topMe = parseInt(q.Nodes.MainCase.style.top);
            with (q.DragPos) {
                x = mouseX;
                y = mouseY;
            }
            with (q.BackPos) {
                x = leftMe;
                y = topMe;
            }
            //document.body.style.cursor="move";
        }
        q.Moving = function (event) {
            if (!q.Draging) return;
            if (q.IsModal) {
                q.Nodes.ModalLayer.style.display = "none";
            }
            var posX = q.GetPointerX(event);
            var posY = q.GetPointerY(event);
            var leftMe = parseInt(q.Nodes.MainCase.style.left);
            var topMe = parseInt(q.Nodes.MainCase.style.top);
            var posNowX = posX - q.DragPos.x + leftMe;
            var posNowY = posY - q.DragPos.y + topMe;
            with (q.Nodes.MainCase.style) {
                left = posNowX + "px";
                top = posNowY + "px";
            }
            q.DragPos.x = posX;
            q.DragPos.y = posY;
        }
        q.StopMove = function (event) {
            if (!q.Draging) return;
            if (q.IsModal) {
                q.Nodes.ModalLayer.style.display = "block";
            }
            q.Draging = false;
            $vs.removeHandler(document, "mousemove", q.Moving);
            $vs.removeHandler(document, "mouseup", q.StopMove);
            $vs.removeHandler(document, "selectstart", q.ReturnFalse);
            var mouseX = q.GetPointerX(event) - (document.documentElement.scrollLeft || document.body.scrollLeft);
            var mouseY = q.GetPointerY(event) - (document.documentElement.scrollTop || document.body.scrollTop);
            if (mouseX < 1 || mouseY < 1 || mouseX > document.body.clientWidth || mouseY > document.body.clientHeight) {
                q.Nodes.MainCase.style.left = q.BackPos.x + "px";
                q.Nodes.MainCase.style.top = q.BackPos.y + "px";
            };
            with (q.LastPos) {
                Left = parseInt(q.Nodes.MainCase.style.left);
                Top = parseInt(q.Nodes.MainCase.style.top);
                OffsetWidth = parseInt(q.Nodes.MainCase.offsetWidth);
                OffsetHeight = parseInt(q.Nodes.MainCase.offsetHeight);
            }
            //document.body.style.cursor="";
        }
        q.BindMoveHandler = function (node) {
            $vs.addHandler(node, "mousedown", q.StartMove);
        }
        q.ViewTop = function () {
            vs.Layer.Private2.SetActived(Me);
        }
        var baseDestroy = q.Destroy;
        q.Destroy = function () {
            vs.Layer.Private2.DeleteLayer(Me);
            if (q.IsModal) {
                q.Nodes.ModalLayer.removeNode(true);
            }
            baseDestroy();
        }
        var AttachEvent = function () {
            $vs.addHandler(q.Nodes.MainCase, "mousedown", q.ViewTop);
        }
    }
}
$vs.initType(vsClass);


vsClass = vs.Window = function () {
    with ($vs) {
        var q = $vs.inherit(this, arguments, vs.Layer);
        if (!String) q = vs.Layer.Q;

        var Static = q.Static;
        if (Static.Private3 == null) {
            Static.Private3 = new function () {
                var S = this;
                var WindowArray = [];
                var LastPos = { Left: 100, Top: 0 }
                var WindowSet = { Width: 10, Height: 10 };

                $vs.addEvent(S, "MinView"); //最小化一个窗体,参数(window)
                $vs.addEvent(S, "Show"); //显示一个窗体,参数(window)
                $vs.addEvent(S, "Close"); //关闭一个窗体,参数(window)
                $vs.addEvent(S, "ChgTitle"); //一个窗体的标题变化了,参数(window)
                S.NewWindow = function (window) {
                    //Static.Private2.NewLayer(window);
                    WindowArray.push(window);
                }
                S.DeleteWindow = function (windowMe) {
                    var zIndexOfMe = windowMe.GetZIndex();
                    for (var i = 0, count = WindowArray.length; i < count; i++) {
                        var zIndex = WindowArray[i].GetZIndex();
                        if (zIndexOfMe == zIndex) {
                            WindowArray.splice(i, 1);
                            break;
                        }
                    }
                }
                S.GetShowInTopWindow = function () {
                    ///<returns type="vs.Window.Type">显示在最上面的窗口,若全都未显示,则置为空</returns>
                    var topWindow = null;
                    for (var i = 0, count = WindowArray.length; i < count; i++) {
                        var win = WindowArray[i];
                        if (!String) win = vs.Layer.Demo;
                        if (win.GetIsShow()) {
                            if (topWindow == null) {
                                topWindow = win;
                            } else if (win.GetZIndex() > topWindow.GetZIndex()) {
                                topWindow = win;
                            }
                        }
                    }
                    return topWindow;
                }
                S.NewPos = function () {
                    var pos = { Left: 0, Top: 0 };
                    pos.Left = LastPos.Left;
                    pos.Top = LastPos.Top;
                    LastPos.Left += 20;
                    LastPos.Top += 20;
                    if (LastPos.Left > 300) {
                        LastPos.Left = 100;
                        LastPos.Top = 0;
                    }
                    return pos;
                }
                S.NewCenterPos = function (myWidth, myHeight) {
                    var pos = { Left: 0, Top: 0 };
                    if (WindowSet.Width > myWidth) {
                        pos.Left += ((WindowSet.Width - myWidth) / 2) + (document.documentElement.scrollLeft || document.body.scrollLeft);
                    }
                    if (WindowSet.Height > myHeight) {
                        pos.Top += ((WindowSet.Height - myHeight) / 2) + (document.documentElement.scrollTop || document.body.scrollTop);
                    }
                    return pos;
                }
                S.KeepResize = function (width, height) {
                    WindowSet.Width = width;
                    WindowSet.Height = height;
                };
                S.GetWindow = function () {
                    var topWindow = { Width: 0, Height: 0 };
                    topWindow.Width = WindowSet.Width;
                    topWindow.Height = WindowSet.Height;
                    return topWindow;
                }
                S.CloseAllWindow = function () {
                    for (var i = 0, count = WindowArray.length; i < count; i++) {
                        WindowArray[i].Close(true);
                    }
                }
            }
        }
        var Me = this;
        vs.Window.Private3.NewWindow(Me);

        $vs.addEvent(Me, "Resized");
        $vs.addEvent(Me, "Closing");     //准备关闭而不是卸载窗口
        $vs.addEvent(Me, "Closed");     //已经关闭窗口
        $vs.addEvent(Me, "UnLoaded"); //卸载窗口

        Me.EnumWindowState = q.EnumWindowState = { Normal: 0, Minimized: 1, Maximized: 2 };
        Me.EnumStartPosition = q.EnumStartPosition = { WindowsDefaultLocation: 0, CenterScreen: 1 }
        Me.WindowState = q.WindowState = q.EnumWindowState.Common;
        q.StartPosition = q.EnumStartPosition.WindowsDefaultLocation;

        q.Nodes.TBody = dom.TBody;
        q.Nodes.TitleLine = dom.TD;
        q.Nodes.ContentRow = dom.TR;
        q.Nodes.ContentCase = dom.TD;
        q.Nodes.ContentViewScroll = dom.Node;
        q.Nodes.ContentView = dom.Node;
        q.Nodes.ContentCover = dom.Div;
        q.Nodes.TitleCase = dom.TBody;
        q.Nodes.TitleRow = dom.TR;
        q.Nodes.TitleLeft = dom.TD;
        q.Nodes.TitleLog = dom.TD;
        q.Nodes.TitleLogView = dom.Node;
        q.Nodes.TitleView = dom.TD;
        q.Nodes.TitleNode = dom.Node;
        q.Nodes.TitleBox = dom.TD;
        q.Nodes.MinViewGo = dom.Button;
        q.Nodes.MaxViewGo = dom.Button;
        q.Nodes.NormalViewGo = dom.Button;
        q.Nodes.CloseViewGo = dom.Button;
        q.Nodes.TitleRight = dom.TD;

        q.Nodes.StatusBar = dom.TD;
        q.Nodes.StatusBarView = dom.Node;
        q.Nodes.StatusViewMain = dom.TD;
        q.Nodes.StatusView1 = dom.TD;
        q.Nodes.StatusView2 = dom.TD;
        q.Nodes.StatusView3 = dom.TD;
        q.Nodes.StatusView4 = dom.TD;

        q.Nodes.BottomRow = dom.TR;
        q.Nodes.UpHand = dom.Node;
        q.Nodes.LeftHand = dom.TD;
        q.Nodes.RightHand = dom.TD;
        q.Nodes.LeftDownHand = dom.TD;
        q.Nodes.RightDownHand = dom.TD;
        q.Nodes.DownHand = dom.TD;

        q.DefaultContentHeight = 200;
        q.DefaultContentWidth = 500;

        q.IsOnceShowed = false; //是否显示过
        q.LastSize = { Left: 0, Top: 0, Width: 0, Height: 0 };
        q.IsInMax = false; //是否处于最大化状态

        q.MoveHand = vs.MoveHand.Demo;

        q.IsReallyClose = true; //实模式关闭,关闭后完全退出,否则只是隐藏,可以再次show

        var baseSetLayer = q.SetLayer;
        q.SetLayer = function () {
            baseSetLayer();
            with (q.Nodes.ContentCase.style) {
                position = "relative";
            }
        }
        q.SetStyle = function () {
            q.Nodes.MinViewGo.innerHTML = "&nbsp;";
            q.Nodes.MaxViewGo.innerHTML = "&nbsp;";
            q.Nodes.NormalViewGo.innerHTML = "&nbsp;";
            q.Nodes.CloseViewGo.innerHTML = "&nbsp;";
            //q.Nodes.ContentView.style.overflowX = "scroll";
            q.Nodes.ContentViewScroll.style.overflow = "scroll";
            q.Nodes.ContentViewScroll.style.overflowX = "auto";
            with (q.Nodes.ContentCover.style) {
                filter = "alpha(opacity = 1)";
                opacity = 0.01;
            }
            q.Nodes.TitleCase.style["-moz-user-select"] = "none";
        }
        q.ResizeChg = function () {
            var contentWidth = parseInt(q.Nodes.ContentViewScroll.style.width);
            var contentHeight = parseInt(q.Nodes.ContentViewScroll.style.height);
            var titleWidth = contentWidth;
            titleWidth -= parseInt(q.Nodes.TitleLog.offsetWidth);
            titleWidth -= parseInt(q.Nodes.MinViewGo.offsetWidth);
            titleWidth -= parseInt(q.Nodes.MaxViewGo.offsetWidth);
            titleWidth -= parseInt(q.Nodes.NormalViewGo.offsetWidth);
            titleWidth -= parseInt(q.Nodes.CloseViewGo.offsetWidth);
            titleWidth -= 8;
            try { q.Nodes.TitleNode.style.width = titleWidth + "px" } catch (e) {
                q.Nodes.TitleNode.style.width = 0 + "px";
            };
            q.Nodes.TitleCase.style.display = "none";
            //q.Nodes.ContentView.innerHTML = q.Nodes.ContentView.offsetWidth + "|" + q.Nodes.MainCase.offsetWidth;
            q.Nodes.UpHand.style.width = contentWidth - 8 + "px";
            q.Nodes.ContentCover.style.width = (contentWidth + 10) + "px";
            q.Nodes.ContentCover.style.height = contentHeight + "px";
            q.Nodes.ContentView.style.width = (contentWidth - 17) + "px";
            q.ReSetLayer();
            q.Nodes.TitleCase.style.display = "block";
            Me.Resized()
        }
        var baseInit = q.Init;
        q.Init = function (isModal, mainCaseAt) {
            if (arguments.callee.Runed === true) return; arguments.callee.Runed = true;
            baseInit(isModal, mainCaseAt);

            q.Nodes.UpHand = dom.NewDiv("");
            q.Nodes.MainCase.appendChild(q.Nodes.UpHand);
            var table1 = dom.NewTable();
            //		table1.border = 1;
            //		table1.cellPadding = 1;
            //		table1.cellSpacing = 1;
            q.Nodes.TBody = dom.NewTBody(table1);
            for (var i = 0; i < 3; i++) {
                var row = q.Nodes.TBody.insertRow(-1);
                for (var j = 0; j < 3; j++) {
                    var cell = row.insertCell(-1);
                    cell.innerHTML = "";
                }
            }
            var titleRow = q.Nodes.TBody.rows[0];
            q.Nodes.TitleLeft = titleRow.cells[0];
            q.Nodes.TitleLeft.innerHTML = "<div style='width:4px; height:4px; overflow:hidden;'>&nbsp;</div>";
            q.Nodes.TitleLine = titleRow.cells[1];
            q.Nodes.TitleLine.innerHTML = "";
            q.Nodes.TitleRight = titleRow.cells[2];

            var row = q.Nodes.ContentRow = q.Nodes.TBody.rows[1];
            q.Nodes.LeftHand = row.cells[0];
            q.Nodes.ContentCase = row.cells[1];
            if (!String) q.Nodes.ContentCase = dom.TD;
            q.Nodes.ContentCase.vAlign = "top";
            q.Nodes.RightHand = row.cells[2];
            q.Nodes.RightHand.innerHTML = "<div style='width:4px; overflow:hidden;'>&nbsp;</div>";
            q.Nodes.ContentViewScroll = dom.NewDiv();
            q.Nodes.ContentView = dom.NewDiv();
            q.Nodes.ContentCover = dom.NewDiv();

            var row2 = q.Nodes.BottomRow = q.Nodes.TBody.rows[2];
            var row3 = q.Nodes.BottomRow = q.Nodes.TBody.insertRow(-1);
            q.Nodes.LeftDownHand = row2.cells[0];
            if (!String) q.Nodes.LeftDownHand = dom.TD;
            q.Nodes.LeftDownHand.rowSpan = 2;
            q.Nodes.StatusBar = row2.cells[1];
            q.Nodes.RightDownHand = row2.cells[2];
            q.Nodes.RightDownHand.rowSpan = 2;

            q.Nodes.DownHand = row3.insertCell(-1);
            q.Nodes.ContentCase.appendChild(q.Nodes.ContentCover);
            q.Nodes.ContentCase.appendChild(q.Nodes.ContentViewScroll);
            q.Nodes.ContentViewScroll.appendChild(q.Nodes.ContentView);

            if (!String) q.Nodes.StatusBar = dom.TD;
            q.Nodes.StatusBarView = dom.NewDiv();
            q.Nodes.StatusBar.appendChild(q.Nodes.StatusBarView);
            var tableStatus = dom.NewTable();
            tableStatus.style.width = "100%";
            var tbodyStatus = dom.NewTBody(tableStatus);
            var rowStatus = dom.NewRowOfTable(tbodyStatus, -1);
            var cell = rowStatus.insertCell(-1);
            q.Nodes.StatusViewMain = dom.NewDiv("");
            cell.appendChild(q.Nodes.StatusViewMain);
            q.Nodes.StatusView1 = rowStatus.insertCell(-1);
            q.Nodes.StatusView2 = rowStatus.insertCell(-1);
            q.Nodes.StatusView3 = rowStatus.insertCell(-1);
            q.Nodes.StatusView4 = rowStatus.insertCell(-1);
            q.Nodes.StatusViewMain.innerHTML = "状态.";
            q.Nodes.StatusView1.innerHTML = dom.Blank;
            q.Nodes.StatusView2.innerHTML = dom.Blank;
            q.Nodes.StatusView3.innerHTML = dom.Blank;
            q.Nodes.StatusView4.innerHTML = dom.Blank;
            //q.Nodes.StatusView4.innerHTML = "";
            q.Nodes.StatusBarView.appendChild(tableStatus);
            var table2 = dom.NewTable();
            q.Nodes.TitleLine.appendChild(table2);
            q.Nodes.TitleCase = dom.NewTBody(table2);
            table2.appendChild(q.Nodes.TitleCase);
            if (!String) table2 = dom.Table;
            with (table2) {
                style.width = "100%";
                style["-moz-user-select"] = "none";
            }
            q.Nodes.TitleRow = dom.NewTR(q.Nodes.TitleCase);
            q.Nodes.TitleLog = q.Nodes.TitleRow.insertCell(-1);
            q.Nodes.TitleLogView = dom.NewDiv(dom.Blank);
            q.Nodes.TitleLog.appendChild(q.Nodes.TitleLogView);
            q.Nodes.TitleView = dom.NewTD(q.Nodes.TitleRow, -1, "");
            q.Nodes.TitleNode = dom.NewDiv("窗口");
            q.Nodes.TitleNode.style["textOverflow"] = "ellipsis";
            q.Nodes.TitleView.appendChild(q.Nodes.TitleNode);
            q.Nodes.TitleBox = q.Nodes.TitleRow.insertCell(-1);

            q.Nodes.MinViewGo = dom.NewButton();
            q.Nodes.MaxViewGo = dom.NewButton();
            q.Nodes.NormalViewGo = dom.NewButton();
            q.Nodes.CloseViewGo = dom.NewButton();

            q.Nodes.TitleBox.appendChild(q.Nodes.MinViewGo);
            q.Nodes.TitleBox.appendChild(q.Nodes.MaxViewGo);
            q.Nodes.TitleBox.appendChild(q.Nodes.NormalViewGo);
            q.Nodes.TitleBox.appendChild(q.Nodes.CloseViewGo);

            q.Nodes.MainCase.appendChild(table1);
            q.BindSelfSkin("vs_Window");
            q.SetStyle();


            q.MoveHand = new vs.MoveHand();
            if (!String) q.MoveHand = vs.MoveHand.Demo;
            AttachEvent();
        }
        Me.Init = q.Load = function (nodeOrHtml, isModal, width, height, mainCaseAt) {
            var type = typeof (nodeOrHtml);
            if (type != "string") {
                //2009-4-24 为支持微软的验证控件，不能直接使用appendChild来追加
                var mainCaseAt = document.createElement("span");
                mainCaseAt.id = "win33";
                //		    mainCaseAt.title = "浮动窗口";
                //		    mainCaseAt.style.border = "1px solid red";
                if (!String) nodeOrHtml = vs.dom.Node.Q;
                nodeOrHtml.parentNode.insertBefore(mainCaseAt, nodeOrHtml);
            }
            q.Init(isModal, mainCaseAt);
            if (q.IsModal) q.Nodes.ModalLayer.style.display = "none";
            if (height < 100) height = 100;
            if (width < 200) width = 200;
            if (type == "string") {
                q.Nodes.ContentView.innerHTML = nodeOrHtml;
            } else if (type == "object" && nodeOrHtml.nodeType == dom.Node.EnumNodeType.Element) {
                //2009-4-24 为支持微软的验证控件，不能直接使用appendChild来追加
                var span = document.createElement("span");
                if (!String) span = vs.dom.Node.Q;
                q.Nodes.ContentView.appendChild(span);
                span.replaceNode(nodeOrHtml);
            }
            width = ((width == null) ? parseInt(q.Nodes.MainCase.offsetWidth) : width) - 8;
            height = ((height == null) ? parseInt(q.Nodes.MainCase.offsetHeight) : height) - parseInt(q.Nodes.TitleCase.offsetHeight) - parseInt(q.Nodes.StatusBar.offsetHeight) - 4;
            q.Nodes.ContentViewScroll.style.width = (width - 8) + "px";
            q.Nodes.ContentViewScroll.style.height = height + "px";

            q.MoveHand.Load(q.Nodes.MainCase, q.Nodes.ContentViewScroll, q.Nodes.UpHand, q.Nodes.RightHand, q.Nodes.DownHand, q.Nodes.LeftHand, q.Nodes.TitleRight, q.Nodes.RightDownHand, q.Nodes.LeftDownHand, q.Nodes.TitleLeft);
            q.Nodes.MainCase.style.display = "none";
            //q.ResizeChg();
        }
        Me.SetCenterStartPosition = q.SetCenterStartPosition = function () {
            q.StartPosition = q.EnumStartPosition.CenterScreen;
        }
        Me.SetMinView = q.SetMinView = function () {
            with (q.LastSize) {
                Left = q.LastPos.Left;
                Top = q.LastPos.Top;
                Width = q.LastPos.Width;
                Height = q.LastPos.Height;
            }
            q.Nodes.TitleCase.focus();
            if (q.IsModal) q.Nodes.ModalLayer.style.display = "none";
            q.Nodes.MainCase.style.display = "none";
            vs.Window.Private3.MinView(Me);
            Me.WindowState = q.WindowState = q.EnumWindowState.Minimized;
        }
        Me.SetMaxView = q.SetMaxView = function () {
            with (q.LastSize) {
                Left = q.LastPos.Left;
                Top = q.LastPos.Top;
                Width = q.LastPos.Width;
                Height = q.LastPos.Height;
            }
            if (q.IsModal) q.Nodes.ModalLayer.style.display = "block";
            q.Nodes.MainCase.style.display = "block";
            q.Nodes.NormalViewGo.style.display = "inline";
            q.Nodes.MaxViewGo.style.display = "none";

            var topWin = vs.Window.Private3.GetWindow();
            with (q.Nodes.MainCase.style) {
                left = -4 + "px";
                top = 0 + "px";
            }
            with (q.Nodes.ContentViewScroll.style) {
                width = (topWin.Width) + "px";
                height = (topWin.Height - parseInt(q.Nodes.TitleCase.offsetHeight) - parseInt(q.Nodes.StatusBar.offsetHeight)) + "px";
            }
            Me.WindowState = q.WindowState = q.EnumWindowState.Maximized;
            q.MoveHand.HideAll();
            q.ResizeChg();
            q.IsInMax = true;
        }
        Me.SetNormalView = q.SetNormalView = function () {
            if (q.WindowState == q.EnumWindowState.Normal) {
                q.ViewTop();
                return;
            }
            if (q.IsModal) q.Nodes.ModalLayer.style.display = "block";
            q.Nodes.MainCase.style.display = "block";
            q.Nodes.NormalViewGo.style.display = "none";
            q.Nodes.MaxViewGo.style.display = "inline";
            var win = vs.Window.Private3.GetWindow();
            if (!q.IsOnceShowed) {
                var pos = { Left: 0, Top: 0 };
                switch (q.StartPosition) {
                    case q.EnumStartPosition.WindowsDefaultLocation:
                        pos = vs.Window.Private3.NewPos();
                        var myHeight = parseInt(q.Nodes.MainCase.offsetHeight);
                        if (myHeight + pos.Top > win.Height) {
                            pos.Top -= (myHeight + pos.Top) - win.Height;
                            if (pos.Top < 0) pos.Top = 0;
                        }
                        var myWidth = parseInt(q.Nodes.MainCase.offsetWidth);
                        if (myWidth + pos.Left > win.Width) {
                            pos.Top = (myWidth + pos.Left) - win.Width;
                            if (pos.Left < 0) pos.Left = 0;
                        }
                        break;
                    case q.EnumStartPosition.CenterScreen:
                        pos = vs.Window.Private3.NewCenterPos(parseInt(q.Nodes.MainCase.offsetWidth), parseInt(q.Nodes.MainCase.offsetHeight));
                        break;
                }
                with (q.Nodes.MainCase.style) {
                    left = pos.Left + "px";
                    top = pos.Top + "px";
                }
            } else {
                with (q.Nodes.MainCase.style) {
                    left = q.LastSize.Left + "px";
                    top = q.LastSize.Top + "px";
                }
                with (q.Nodes.ContentViewScroll.style) {
                    width = q.LastSize.Width + "px";
                    height = q.LastSize.Height + "px";
                }
            }
            Me.WindowState = q.WindowState = q.EnumWindowState.Normal;
            q.MoveHand.ShowAll();
            q.ResizeChg();
            q.IsInMax = false;
        }
        Me.ChgActive = q.ChgActive = function () {
            ///<returns type="Boolean">是否置顶显示</returns>
            var topWin = vs.Window.Private3.GetShowInTopWindow();
            if (q.Nodes.MainCase.style.display == "none") {
                //			if(q.IsModal)q.Nodes.ModalLayer.style.display = "block";
                //			q.Nodes.MainCase.style.display = "block";
                q.ViewTop();
                if (q.IsInMax) {
                    q.SetMaxView();
                } else {
                    q.SetNormalView();
                }
                return true;
            } else if (topWin != Me) {
                q.ViewTop();
                return true;
            } else {
                q.SetMinView();
                return false;
            }
        }
        Me.SetActived = q.SetActived = function () {
            if (q.WindowState == q.EnumWindowState.Minimized) return;
            var topWin = vs.Window.Private3.GetShowInTopWindow();
            if (q.Nodes.MainCase.style.display == "none") {
                if (q.IsModal) q.Nodes.ModalLayer.style.display = "block";
                q.Nodes.MainCase.style.display = "block";
            }
            if (topWin != Me) q.ViewTop();
            if (q.IsInMax) {
                q.SetMaxView();
            } else {
                q.SetNormalView();
            }
        }
        Me.Show = q.Show = function () {
            if (q.IsModal) q.Nodes.ModalLayer.style.display = "block";
            q.Nodes.MainCase.style.display = "block";
            vs.Layer.Private2.SetActived(Me);

            q.SetNormalView();
            with (q.LastPos) {
                Left = parseInt(q.Nodes.MainCase.style.left);
                Top = parseInt(q.Nodes.MainCase.style.top);
            }
            if (q.IsReallyClose) vs.Window.Private3.Show(Me);
            q.IsOnceShowed = true;
            q.ResizeChg();
            var contentWidth = parseInt(q.Nodes.ContentViewScroll.style.width);
            var contentHeight = parseInt(q.Nodes.ContentViewScroll.style.height);
            with (q.LastPos) {
                Width = contentWidth;
                Height = contentHeight;
            }
            with (q.LastSize) {
                Left = q.LastPos.Left;
                Top = q.LastPos.Top;
                Width = q.LastPos.Width;
                Height = q.LastPos.Height;
            }
        }
        Me.Close = q.Close = function (isUnload) {
            isUnload = (isUnload === true) ? true : false;
            if (isUnload) {
                Me.UnLoaded();
            } else {
                if (!Me.Closing()) return;
            }
            if (q.IsModal) q.Nodes.ModalLayer.style.display = "none";
            with (q.Nodes) {
                //if(ModalLayer.removeNode)ModalLayer.removeNode(true);
                MainCase.style.display = "none";
                if (!q.IsReallyClose) return;
                vs.Window.Private3.Close(Me, isUnload);
                MainCase.innerHTML = "";
                if (MainCase.removeNode) MainCase.removeNode(true);
            }
            Me.Closed();
            window.setTimeout(q.Destroy, 1);
        }
        Me.Hide = q.Hide = function () {
            if (q.IsModal) q.Nodes.ModalLayer.style.display = "none";
            q.Nodes.MainCase.style.display = "none";
        }
        Me.GetTitle = q.GetTitle = function () {
            return q.Nodes.TitleNode.innerText;
        }
        Me.SetTitle = q.SetTitle = function (newTitle) {
            q.Nodes.TitleNode.innerText = newTitle;
            vs.Window.Private3.ChgTitle(Me);
        }
        Me.SetMinGoEnable = q.Acts.SetMinGoEnable = function (able) {
            q.Nodes.MinViewGo.style.visibility = able ? "visiable" : "hidden";
        }
        Me.SetMaxGoEnable = q.Acts.SetMaxGoEnable = function (able) {
            q.Nodes.MaxViewGo.style.visibility = able ? "visiable" : "hidden";
        }
        Me.GetIsOnceShowed = q.GetIsOnceShowed = function () {
            return q.IsOnceShowed;
        }
        q.LightStatusIndex = 0;
        q.LightStatusTimer = 0;
        q.LightStatus = function () {
            try {
                var index = q.LightStatusIndex;
                if (index <= 0) {
                    q.Nodes.StatusViewMain.style.color = "";
                    return;
                }
                q.Nodes.StatusViewMain.style.color = (index % 2 == 0) ? "red" : "blue";
                q.LightStatusIndex--;
                q.LightStatusTimer = window.setTimeout(q.LightStatus, 1000);
            } catch (e) { }
        }
        Me.SetStatus = q.SetStatus = function (status) {
            q.Nodes.StatusViewMain.innerText = status;
            q.Nodes.StatusViewMain.title = q.Nodes.StatusViewMain.LastTitle + "\r\n" + status;
            q.Nodes.StatusViewMain.LastTitle = status;
            q.LightStatusIndex = 4;
            q.LightStatus();
        }
        var baseDestroy = q.Destroy;
        q.Destroy = function () {
            vs.Window.Private3.DeleteWindow(Me);
            window.clearTimeout(q.LightStatusTimer);
            baseDestroy();
        }
        q.Handlers.WindowMaxChg = function () {
            if (q.WindowState == q.EnumWindowState.Maximized) {
                q.SetNormalView();
            } else {
                q.SetMaxView();
            }
            return false;
        }
        var AttachEvent = function () {
            q.BindMoveHandler(q.Nodes.TitleView);
            $vs.addHandler(q.Nodes.TitleCase, "mousedown", function () {
                q.Nodes.ContentCover.style.display = "block";
            });
            $vs.addHandler(q.Nodes.TitleCase, "mouseup", function () {
                q.Nodes.ContentCover.style.display = "none";
            });
            $vs.addHandler(q.Nodes.TitleView, "dblclick", q.Handlers.WindowMaxChg);
            $vs.addHandler(q.Nodes.CloseViewGo, "click", q.Close);
            $vs.addHandler(q.Nodes.MinViewGo, "click", q.SetMinView);
            $vs.addHandler(q.Nodes.MaxViewGo, "click", q.SetMaxView);
            $vs.addHandler(q.Nodes.NormalViewGo, "click", q.SetNormalView);
            Me.OnToStartMove.push(function (me) {
                if (me.WindowState == q.EnumWindowState.Maximized) {
                    return false;
                }
            });
            q.MoveHand.OnStarted.push(function () {
                if (q.IsModal) q.Nodes.ModalLayer.style.display = "none";
                q.Nodes.ContentCover.style.display = "block";
            })
            q.MoveHand.OnStoped.push(function () {
                if (q.IsModal) q.Nodes.ModalLayer.style.display = "block";
                q.Nodes.ContentCover.style.display = "none";
                q.ResizeChg();
                var contentWidth = parseInt(q.Nodes.ContentViewScroll.style.width);
                var contentHeight = parseInt(q.Nodes.ContentViewScroll.style.height);
                with (q.LastPos) {
                    Width = contentWidth;
                    Height = contentHeight;
                }
            });
        }
    } 
}
$vs.initType(vsClass);

vsClass.$new = function (nodeOrHtml, isModal, width, height) {
    ///<returns type="vs.Window.Type"></returns>
    return this.New.apply(this, arguments);
}
/// <reference path="vs.Window.js" />
vsClass = vs.MasterPage = function () {
    with ($vs) {
        var q = $vs.inherit(this, arguments, vs.Pager);
        if (!String) q = vs.Pager.Q;

        var Me = this;
        $vs.addEvent(Me, "Loaded");
        $vs.addEvent(Me, "Resized");
        $vs.addEvent(Me, "WindowViewBinded");
        $vs.addEvent(Me, "Closing"); //正在关闭窗体,参数()
        q.HasClosed = false;
        q.LastBodyWidth = -1;
        q.LastBodyHeight = -1;
        q.WindowSizer = null;
        q.WindowView = vs.Window.Demo;
        q.Inited = false;
        q.ScrollNeed = 17;
        q.ScrollIsShow = false;
        Me.ContentView = q.ContentView = dom.Div;

        Me.Load = q.Load = function () {
            if ($vs.browser.isIE) {
                q.WindowSizer = document.getElementsByTagName("HTML")[0];
                if ($vs.config.isOneDesktop && window != top) {
                    document.body.style.overflow = "visible";
                    document.body.style.width = "auto";
                }
            } else {
                q.WindowSizer = document.body;
            }
            if ($vs.config.isOneDesktop && window != top) {
                with (q.WindowSizer.style) {
                    overflowY = "scroll";
                    overflowX = "auto";
                }
            }
            Me.ContentView = q.ContentView = $vs.doc.GetDiv("ContentView");
            if (q.ContentView == null) {
                var form = document.getElementById("vsform");
                if (form) {
                    var div = $vs.dom.NewDiv();
                    document.body.appendChild(div);
                    div.appendChild(form);
                    Me.ContentView = q.ContentView = div;
                }
            }
            q.WindowView = null;
            if (window != top && parent.vs != null && parent.vs.NaviWindow != null) {
                Me.WindowView = q.WindowView = parent.vs.NaviWindow.Private4.GetWindowByName(window.name);
                if (q.WindowView != null) Me.WindowViewBinded();
            }
            AttachEvent();
            q.Inited = true;
            Me.Loaded();
            var MasterPage = window.MasterPage = this;
        }

        Me.ResizedGo = q.ResizedGo = function () {
            if (!q.Inited) return;
            var xScroller = !(document.body.style.overflow == "hidden" || document.body.style.overflowX == "hidden");
            var winWidth = q.WindowSizer.offsetWidth + (xScroller ? -18 : 0);
            var winHeight = q.WindowSizer.offsetHeight;
            //        if(window != top && winWidth > q.ScrollNeed){
            if (winWidth > q.ScrollNeed) {
                winWidth -= q.ScrollNeed;
                if (q.ContentView) with (q.ContentView.style) {
                    width = winWidth + "px";
                }
                q.ScrollIsShow = true;
            }
            if (q.LastBodyWidth != winWidth || q.LastBodyHeight != winHeight) {
                Me.Resized(winWidth, winHeight);
            }
            vs.Window.Private3.KeepResize(winWidth, winHeight);
            vs.MoveHand.Private2.KeepResize(winHeight);
        }
        Me.ShowLoginPannel = q.ShowLoginPannel = function (onSuccess) {
            q.LoginOKHandler = onSuccess;
            q.LoginPanel.Show();
        }
        Me.GetUserLoginOK = q.GetUserLoginOK = function () {
            return (q.LoginUser.ID != -1);
        }
        Me.GetUserID = q.GetUserID = function () {
            return q.LoginUser.ID;
        }
        Me.GetUserEmail = q.GetUserEmail = function () {
            return q.LoginUser.Email;
        }
        Me.GetUserName = q.GetUserName = function () {
            return q.LoginUser.Name;
        }
        var AttachEvent = function () {
            $vs.addHandler(window, "resize", q.ResizedGo);
            $vs.addHandler(document.body, "focus", function () { });
            if (q.WindowView != null) {
                q.WindowView.OnClosing.push(function () {
                    var act = Me.Closing();
                    if (act) q.HasClosed = true;
                    return act;
                });
            }
            $vs.addHandler(window, "unload", function () {
                if (!q.HasClosed) Me.Closing();
                vs.Window.Private3.CloseAllWindow();
            });
            //		if(document.forms[0])document.forms[0].onsubmit = function(){
            //			javascript:return false;
            //		};
            $vs.addHandler(document.body, "mousedown", function () {
                if (q.WindowView != null) {
                    q.WindowView.SetActived();
                }
            });
        }
        Me.CloseWindow = q.CloseWindow = function () {
            if (q.WindowView == null) return false;
            q.WindowView.Close();
        }
        Me.SetStatus = q.SetStatus = function (status) {
            if (q.WindowView == null) return false;
            q.WindowView.SetStatus(status);
        }
        Me.SetTitle = q.SetTitle = function (title) {
            if (q.WindowView == null) return false;
            q.WindowView.SetTitle(title);
        }
        Me.SetActived = q.SetActived = function () {
            if (q.WindowView == null) return false;
            q.WindowView.SetActived();
        }
        //    Me.GetWindowView = q.GetWindowView = function(){
        //		return q.WindowView;
        //    }

        Me.OnLoaded_End.push(function () {
            if (q.LastBodyHeight == -1) {
                q.ResizedGo();
            } else {
                Me.Resized(q.LastBodyWidth, q.LastBodyHeight);
            }
        });
    } 
}
$vs.initType(vsClass);

/// <reference path="vs_common.js" />
/// <reference path="dom.js" />
vsClass = vs.Validater = function () {
    with ($vs) {
        var q = inherit(this, arguments, vs.Control);
        if (!String) q = vs.Control.Q;

        var Me = this;
        q.Nodes.MessagePanel = dom.Div;
        q.Config.FontColor = "white";
        q.Config.BackgroundColor = "#FEA001";
        q.Config.MinWidth = 40;
        q.Config.MinHeight = 20;
        q.Config.DateTimeFormat = "yyyy-M-d H:m:s";
        q.Acts.Resize = function () {
            with (q.Nodes) {
                var viewWidth = (MainCase.offsetWidth >= q.Config.MinWidth) ? MainCase.offsetWidth : q.Config.MinWidth;
                var viewHeight = (MainCase.offsetHeight >= q.Config.MinHeight) ? MainCase.offsetHeight : q.Config.MinHeight;
                var isEmpty = Object.isNullOrEmpty(MessagePanel.innerText);
                with (MessagePanel.style) {
                    width = (isEmpty ? 1 : viewWidth) + "px";
                    height = (isEmpty ? 1 : viewHeight) + "px";
                    backgroundColor = q.Config.BackgroundColor;
                    color = q.Config.FontColor;
                }
            } 
        }
        q.Info.YellowFadeTimer = null;
        q.Info.YellowFadeOpacity = 100;
        q.Info.BindedHandlers = [];
        q.Acts.YellowFade = function () {
            window.clearTimeout(q.Info.YellowFadeTimer);
            opacity = q.Info.YellowFadeOpacity;
            if (opacity == 0) {
                q.Nodes.MessagePanel.innerHTML = "";
                q.Acts.Resize();
                return;
            }
            q.Nodes.MessagePanel.style.opacity = opacity / 100;
            q.Nodes.MessagePanel.style.filter = String.format("alpha(opacity={0})", opacity);
            q.Info.YellowFadeOpacity = opacity - 20;
            q.Info.YellowFadeTimer = window.setTimeout(q.Acts.YellowFade, (opacity == 100) ? 200 : 80);
        }
        q.Acts.ShowMessage = function (msg) {
            q.Nodes.MessagePanel.innerText = msg;
            q.Nodes.MessagePanel.title = msg;
            q.Info.YellowFadeOpacity = 100;
            q.Acts.Resize();
            q.Acts.YellowFade();
        }

        Me.Init = q.Acts.Init = function (input) {
            with ($vs) {
                if (input == null) throw new Error("要验证的控件不存在！");
                q.Nodes.MainCase = input;
                var panel = input.MessagePanel;
                if (!panel) {
                    panel = q.Nodes.MessagePanel = dom.NewDiv();
                    input.parentNode.insertBefore(panel, input);
                }
                with (panel.style) {
                    position = "absolute";
                    width = "1px";
                    height = "1px";
                    overflow = "hidden";
                    backgroundColor = q.Config.BackgroundColor;
                    color = q.Config.FontColor;
                }
                q.BindSelfSkin("vs_Validater");
                q.AddClass(q.Nodes.MessagePanel, "vs_Validater_MessagePanel");
                AttachEvent();
            } 
        }
        Me.Run = q.Handlers.Run = function () {
            ///<summary>执行绑定的验证</summary>
            for (var i = 0, count = q.Info.BindedHandlers.length; i < count; i++) {
                q.Info.BindedHandlers[i]();
            }
        }

        q.Handlers.FocusBack = function () {
            var input = q.Nodes.MainCase;
            input.focus(); input.select();
        }
        q.Handlers.KeepTrim = function () {
            var input = q.Nodes.MainCase;
            var oldValue = "" + input.value;
            var newValue = oldValue.trim();
            if (newValue != oldValue) {
                input.value = newValue;
                q.Acts.ShowMessage("已自动去除两端空白字符！");
            }
            input.RealValue = newValue;
        }
        q.Handlers.KeepTrimStart = function () {
            var input = q.Nodes.MainCase;
            var oldValue = "" + input.value;
            var newValue = oldValue.trimStart();
            if (newValue != oldValue) {
                input.value = newValue;
                q.Acts.ShowMessage("已自动去除前端空白字符！");
            }
            input.RealValue = newValue;
        }
        q.Handlers.KeepTrimEnd = function () {
            var input = q.Nodes.MainCase;
            var oldValue = "" + input.value;
            var newValue = oldValue.trimEnd();
            if (newValue != oldValue) {
                this.value = newValue;
                q.Acts.ShowMessage("已自动去除后端空白字符！");
            }
            input.RealValue = newValue;
        }
        q.Handlers.KeepNumber = function () {
            var input = q.Nodes.MainCase;
            var oldValue = "" + input.value;
            if (oldValue == "") return;
            var newValue = oldValue.trim();
            var numberValue = parseFloat(newValue);
            if (Object.isNullOrEmpty(numberValue)) {
                if (window.confirm("非法数值，是否置空！")) {
                    input.value = "";
                } else {
                    window.setTimeout(q.Handlers.FocusBack, 1);
                }
                input.RealValue = null;
                return;
            }
            if ("" + numberValue != oldValue) {
                input.value = numberValue;
                q.Acts.ShowMessage("已格式化为合法数值！");
            }
            input.RealValue = numberValue;
        }
        q.Handlers.KeepDateTime = function () {
            var input = q.Nodes.MainCase;
            var oldValue = "" + input.value;
            if (oldValue == "") return;
            var newValue = oldValue.trim();
            var dateValue = Date.ParseEnyFormat(newValue);
            if (Object.isNullOrEmpty(dateValue)) {
                //            if(window.confirm("非法日期值，是否置空！")){
                //                input.value = "";
                //            }else{
                //                //window.setTimeout(q.Handlers.FocusBack,1);
                //            }
                input.style.borderBottomColor = "red";
                input.RealValue = null;
                return;
            } else {
                input.style.borderBottomColor = "";
            }
            var newDateString = dateValue.format(q.Config.DateTimeFormat);
            if (newDateString != oldValue) {
                input.value = newDateString;
                q.Acts.ShowMessage("已修正日期值！");
            }
            input.RealValue = dateValue;
        }

        Me.BindTrim = q.Acts.BindTrim = function (checkFirst) {
            if (checkFirst) q.Handlers.KeepTrim();
            q.Info.BindedHandlers.push(q.Handlers.KeepTrim);
        }
        Me.BindTrimStart = q.Acts.BindTrimStart = function (checkFirst) {
            if (checkFirst) q.Handlers.KeepTrimStart();
            q.Info.BindedHandlers.push(q.Handlers.KeepTrimStart);
        }
        Me.BindTrimEnd = q.Acts.BindTrimEnd = function (checkFirst) {
            if (checkFirst) q.Handlers.KeepTrimEnd();
            q.Info.BindedHandlers.push(q.Handlers.KeepTrimEnd);
        }
        Me.BindNumber = q.Acts.BindNumber = function (checkFirst) {
            if (checkFirst) q.Handlers.KeepNumber();
            q.Info.BindedHandlers.push(q.Handlers.KeepNumber);
        }
        Me.BindDateTime = q.Acts.BindDateTime = function (dateTimeFormat, checkFirst) {
            q.Config.DateTimeFormat = Object.isNullOrEmpty(dateTimeFormat, q.Config.DateTimeFormat);
            if (checkFirst) q.Handlers.KeepDateTime();
            q.Info.BindedHandlers.push(q.Handlers.KeepDateTime);
        }
        Me.ClearBinder = q.Acts.ClearBinder = function () {
            q.Info.BindedHandlers = [];
        }
        var AttachEvent = function () {
            $vs.addHandler(q.Nodes.MainCase, $vs.dom.Events.onchange, q.Handlers.Run);
        }
    } 
}
$vs.initType(vsClass);

vsClass.$new = function (input) {
    ///<param name="input">要验证的控件</param>
    ///<returns type="vs.Validater.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="vs_common.js" />
/// <reference path="vs.TreeNode.js" />
vsClass = vs.Tree = function () {
    with ($vs) {
        var q = $vs.inherit(this, arguments, vs.Control);
        if (!String) q = vs.Control.Q;

        var Me = this;
        try {
            q.Bind.TreeNode = vs.TreeNode.Demo;
        } catch (e) { }
        q.Nodes.MainCase = dom.UL;
        var ChildNodes = [];

        var baseInit = q.Init;
        Me.Init = q.Init = function (treeNode) {
            baseInit();
            q.Nodes.MainCase = dom.NewUL();
            q.Bind.TreeNode = treeNode;
            q.BindSelfSkin("vs_Tree");
        }
        Me.IsTop = q.Acts.IsTop = function () {
            return (q.Bind.TreeNode == null);
        }
        Me.AddNode = q.Acts.AddNode = function (treeNode) {
            if (!String) treeNode = vs.TreeNode.Demo;
            var parentNode = q.Bind.TreeNode;
            if (!String) parentNode = vs.TreeNode.Demo;
            q.Nodes.MainCase.appendChild(treeNode.Nodes.MainCase);
            if (parentNode) parentNode.AddChild(treeNode);
            ChildNodes.push(treeNode);
        }
        Me.View = function () {
            //if(!q.Acts.IsTop())return;
            var treeNode;
            for (var i = 0, count = ChildNodes.length; i < count; i++) {
                treeNode = ChildNodes[i];
                if (!String) treeNode = vs.TreeNode.Demo;
                treeNode.View();
            }
        }
    } 
}
$vs.initType(vsClass);
vsClass.$new = function (treeNode) {
    /// <returns type="vs.Tree.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="vs_common.js" />
/// <reference path="dom.js" />
/// <reference path="vs.Tree.js" />
vsClass = vs.TreeNode = function () {
    var q = $vs.inherit(this, arguments, vs.Control);
    if (!String) q = vs.Control.Q;

    var Me = this;
    var dom = $vs.dom;
    $vs.addEvent(Me, "Expanded"); //已经取消折叠状态
    $vs.addEvent(Me, "Folded"); //已经进入折叠状态
    $vs.addEvent(Me, "NeedLoadChilds"); //需要加载子节点
    $vs.addEvent(Me, "Focused"); //选中了
    $vs.addEvent(Me, "Blured"); //取消选中

    q.Events.Expanded = function () { Me.Expanded(); }
    q.Events.Folded = function () { Me.Folded(); }
    q.Events.NeedLoadChilds = function () { Me.NeedLoadChilds(); };
    q.Events.Focused = function () { Me.Focused(); };
    q.Events.Blured = function () { Me.Blured(); };

    q.Nodes.MainCase = dom.LI;
    q.Nodes.LineTable = dom.Table;
    q.Nodes.FoldedImage = dom.Image;
    q.Nodes.EndImage = dom.Image;
    q.Nodes.ExpandedImage = dom.Image;
    q.Nodes.Ico = dom.Label;
    q.Nodes.Link = dom.A;
    q.Nodes.LoadingImage = dom.Image;

    q.Config.ImageFolder = $vs.server.mapPath("~/skin/default/vs_Tree/");
    q.Config.ExpandedImage = q.Config.ImageFolder + "o.gif";
    q.Config.FoldedImage = q.Config.ImageFolder + "c.gif";
    q.Config.EndImage = q.Config.ImageFolder + "e.gif";
    q.Config.LoadingImage = q.Config.ImageFolder + "s.gif";

    q.Info.ParentNode = null;
    q.Info.ChildNodes = [];
    q.Info.AutoExpand = false;
    q.Info.ViewIco = true;
    q.Info.Expanded = false;
    q.Info.NeedLoadChild = false;
    var dom = $vs.dom;

    var baseInit = q.Init;
    Me.Init = q.Init = function (needLoadChild, autoExpand, viewIco) {
        baseInit();
        if (needLoadChild == true) q.Info.NeedLoadChild = true;
        if (autoExpand == true) q.Info.AutoExpand = true;
        if (viewIco == false) q.Info.ViewIco = false;

        q.Nodes.MainCase = dom.NewLI();
        var linkCell;
        var table;
        with (q.Nodes) {
            table = q.Nodes.LineTable = $vs.dom.NewTable(); table.border = 0; table.cellPadding = 0; table.cellSpacing = 0; table.style.width = "100%";
            var row = table.insertRow(-1);
            FoldedImage = row.insertCell(-1);
            FoldedImage.style.display = "none";
            EndImage = row.insertCell(-1);
            EndImage.style.display = "none";
            ExpandedImage = row.insertCell(-1);
            ExpandedImage.style.display = "none";
            Ico = row.insertCell(-1);
            Ico.style.display = q.Info.ViewIco ? "inline" : "none";
            linkCell = row.insertCell(-1);
            LoadingImage = row.insertCell(-1);
            LoadingImage.style.display = "none";

            //			FoldedImage = dom.NewImage(q.Config.FoldedImage);
            //			FoldedImage.style.display = "none";
            //			EndImage = dom.NewImage(q.Config.EndImage);
            //			EndImage.style.display = "none";
            //			ExpandedImage = dom.NewImage(q.Config.ExpandedImage);
            //			ExpandedImage.style.display = "none";
            //			Ico = dom.NewLabel("");
            //			Ico.style.display = q.Info.ViewIco?"inline-block":"none";
            //			LoadingImage = dom.NewImage(q.Config.LoadingImage);
            //			LoadingImage.style.display = "none";
        }
        q.Nodes.Link = dom.NewALink(null, null, dom.Blank);
        with (q.Nodes) {
            MainCase.appendChild(table);
            linkCell.appendChild(Link);
        }
        q.BindSelfSkin("vs_TreeNode");
        AttachEvent();
    }
    Me.SetParentNode = q.SetParentNode = function (parentNode) {
        q.Info.ParentNode = parentNode;
    }
    Me.GetParentNode = q.GetParentNode = function () {
        /// <returns type="vs.TreeNode.Type"></returns>
        return q.Info.ParentNode;
    }
    Me.HasChild = q.HasChild = function () {
        /// <returns type="Boolean"></returns>
        return (q.Info.ChildNodes.length != 0);
    }
    Me.AddChild = q.AddChild = function (childNode) {
        q.Info.ChildNodes.push(childNode);
        childNode.SetParentNode(Me);
    }
    Me.RemoveChild = q.RemoveChild = function (childNode) {
        var childs = q.Info.ChildNodes;
        for (var i = 0; i < childs; i++) {
            if (childs[i] == childNode) {
                childs.splice(i, 1);
                return;
            }
        }
    }
    Me.Expand = q.Acts.Expand = function () {
        if (q.HasChild()) {
            var treeView = q.Nodes.LineTable.nextSibling;
            if (treeView) treeView.style.display = "block";
            q.Nodes.ExpandedImage.style.display = "inline";
            q.Nodes.FoldedImage.style.display = "none";
            with (q.Nodes.Ico.style) {
                backgroundPositionY = "-20px";
            }
            q.Info.Expanded = true;
            q.Events.Expanded();
        } else if (q.Info.NeedLoadChild) {
            q.Nodes.LoadingImage.style.display = "inline";
            with (q.Nodes.Ico.style) {
                backgroundPositionY = "-20px";
            }
            q.Events.NeedLoadChilds();
            q.Info.NeedLoadChild = false;
            q.Acts.Expand();
            q.Nodes.LoadingImage.style.display = "none";
        }
    }
    Me.Fold = q.Acts.Fold = function () {
        var treeView = q.Nodes.LineTable.nextSibling;
        if (treeView) treeView.style.display = "none";
        q.Nodes.ExpandedImage.style.display = "none";
        q.Nodes.FoldedImage.style.display = "inline";
        with (q.Nodes.Ico.style) {
            backgroundPositionY = "0px";
        }
        q.Info.Expanded = false;
        q.Events.Folded();
    }
    Me.GetAllChilds = q.GetAllChilds = function () {
        /// <returns type="Array"></returns>
        return q.Info.ChildNodes.concat([]);
    }
    Me.SetLink = q.SetLink = function (html, href, target) {
        q.Nodes.Link.innerHTML = Object.isNullOrEmpty(html, dom.Blank);
        q.Nodes.Link.href = Object.isNullOrEmpty(href, dom.DoNothingHref);
        q.Nodes.Link.target = Object.isNull(target, dom.A.EnumTarget.Self);
    }
    Me.View = q.View = function () {
        if (q.HasChild()) {
            q.Acts.Expand();
            //			if(q.Info.AutoExpand){
            //				q.Acts.Expand();
            //			}else{
            //				q.Acts.Fold();
            //			}
            var childs = q.Info.ChildNodes;
            for (var i = 0, count = childs.length; i < count; i++) {
                if (childs[i].View) childs[i].View();
            }
        } else if (q.Info.NeedLoadChild) {
            q.Acts.Fold();
            var childs = q.Info.ChildNodes;
            for (var i = 0, count = childs.length; i < count; i++) {
                if (childs[i].View) childs[i].View();
            }
        } else {
            q.Nodes.Ico.style.backgroundPositionY = "-40px";
            q.Nodes.EndImage.style.display = "inline";

            //			if(q.Info.NeedLoadChild){
            //			    q.Acts.Fold();
            //			    var childs = q.Info.ChildNodes;
            //			    for(var i=0,count = childs.length;i<count;i++){
            //				    if(childs[i].View)childs[i].View();
            //			    }
            //			}else{
            //			    q.Nodes.Ico.style.backgroundPositionY = "-40px";
            //			    if(q.Info.NeedLoadChild){
            //				    q.Nodes.FoldedImage.style.display = "inline";
            //			    }else{
            //				    q.Nodes.EndImage.style.display = "inline";
            //			    }
            //			}
        }
        delete (Me.View);
    }
    Me.CreateTree = q.Acts.CreateTree = function () {
        /// <returns type="vs.Tree.Type"></returns>
        var tree = vs.Tree.$new(Me);
        q.Nodes.MainCase.appendChild(tree.Nodes.MainCase);
        return tree;
    }
    q.Handlers.LinkFocus = function (e) {
        var linkArea = this;
        if (!String) linkArea = $vs.dom.A;
        linkArea.style.backgroundColor = "#326ABD";
        linkArea.style.color = "white";
        q.Events.Focused();
    }
    q.Handlers.LinkBlur = function (e) {
        var linkArea = this;
        if (!String) linkArea = $vs.dom.A;
        linkArea.style.backgroundColor = "";
        linkArea.style.color = "black";
        q.Events.Blured();
    }

    var AttachEvent = function () {
        $vs.addHandler(q.Nodes.FoldedImage, $vs.dom.Events.onclick, function (e) {
            q.Acts.Expand();
        });
        $vs.addHandler(q.Nodes.Link, $vs.dom.Events.onfocus, q.Handlers.LinkFocus);
        $vs.addHandler(q.Nodes.Link, $vs.dom.Events.onblur, q.Handlers.LinkBlur);
        $vs.addHandler(q.Nodes.ExpandedImage, $vs.dom.Events.onclick, function (event) {
            q.Acts.Fold();
        });
    }
}
$vs.initType(vsClass);
vsClass.$new = function (needLoadChild, autoExpand, viewIco) {
    /// <param name="needLoadChild">是否需要加载子节点,默认值为true</param>
    /// <param name="autoExpand">初始加载后是否展开,此设置只在needLoadChild为false时有效,默认值为false</param>
    /// <param name="viewIco">是否显示前置ico图标</param>
    /// <returns type="vs.TreeNode.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="vs_common.js" />
/// <reference path="vs.Tree.js" />
vsClass = vs.MultiTree = function () {
    with ($vs) {
        var q = $vs.inherit(this, arguments, vs.Control);
        if (!String) q = vs.Control.Q;

        var Me = this;

        q.Nodes.MainCase = dom.Div;
        q.Info.TopTree = vs.Tree.Demo;

        var baseInit = q.Init;
        Me.Init = q.Init = function (mainCase) {
            baseInit();
            q.Nodes.MainCase = mainCase;
            q.Info.TopTree = null;
            q.BindSelfSkin("vs_MultiTree");
        }
        Me.CreateTopTree = q.Acts.CreateTopTree = function () {
            /// <summary>创建顶部树</summary>
            /// <returns type="vs.Tree.Type"></returns>
            var topTree = vs.Tree.$new();
            q.Info.TopTree = topTree;
            return topTree;
        }
        Me.View = q.Acts.View = function () {
            var topTree = q.Info.TopTree;
            if (topTree) {
                q.Nodes.MainCase.appendChild(topTree.Nodes.MainCase);
                topTree.View();
            }
        }
    } 
}
$vs.initType(vsClass);
vsClass.$new = function (mainCase) {
    /// <returns type="vs.MultiTree.Type"></returns>
    return this.New.apply(this, arguments);
}



/// <reference path="vs_common.js" />
/// <reference path="dom.js" />
/// <reference path="vs.MultiTree.js" />
vsClass = vs.TreeBinder = function () {
    with ($vs) {
        var q = $vs.inherit(this, arguments, vs.Object);
        if (!String) q = vs.Object.Q;
        var Me = this;
        $vs.addEvent(Me, "NodeTextClicked");
        $vs.addEvent(Me, "NodeTextDblClicked");

        q.Events.NodeTextClicked = function () {
            ///<summary>单击了树节点</summary>
            Me.NodeTextClicked();
        }

        q.Events.NodeTextDblClicked = function () {
            ///<summary>双击了树节点</summary>
            Me.NodeTextDblClicked();
        }

        q.Nodes.MainCase = dom.Node;
        q.Info.MultiTree = vs.MultiTree.Demo;
        q.Info.TreeData = { text: "", href: "", target: "Main", ico: null, childs: [
        { text: "", href: "" }, { text: "", href: "" }
    ]
        };
        q.Info.LastClickNode = null;
        q.Info.LastClickNodeData = null;
        q.Config.Target = "Main";

        //委托
        Me.Handlers = {};
        Me.Handlers.ReadChilds = q.Handlers.ReadChilds = function (obj) {
            ///<summary>读取节点对象的子元素数组，不存在请返回[]</summary>
            ///<returns type="Array"><returns>
            return obj.childs;
        }
        Me.Handlers.ReadText = q.Handlers.ReadText = function (obj) {
            ///<summary>读取节点对象的显示文本</summary>
            ///<returns type="String"><returns>
            return obj.text;
        }
        Me.Handlers.ReadHref = q.Handlers.ReadHref = function (obj) {
            ///<summary>读取节点对象的链接文本</summary>
            ///<returns type="String"><returns>
            return obj.href;
        }
        Me.Handlers.ReadTarget = q.Handlers.ReadTarget = function (obj) {
            ///<summary>读取节点对象的链接目标窗体名称</summary>
            ///<returns type="String"><returns>
            return Object.isNull(obj.target, "");
        }
        Me.Handlers.ReadIco = q.Handlers.ReadIco = function (obj) {
            ///<summary>读取节点对象的前置图标URL,可使用$vs.server.mapPath来实现对"~"开头的绝对路径</summary>
            ///<returns type="String"><returns>
            return Object.isNullOrEmpty(obj.ico, null);
        }
        Me.Handlers.ReadNeedLoadChild = q.Handlers.ReadNeedLoadChild = function (obj) {
            ///<summary>读取节点对象是否还需要动态追加子节点</summary>
            ///<returns type="Boolean"><returns>
            return Object.isNull(obj.needLoadChild, false);
        }
        Me.Handlers.ReadAutoExpand = q.Handlers.ReadAutoExpand = function (obj) {
            ///<summary>读取节点对象的加载后就自动展开</summary>
            ///<returns type="Boolean"><returns>
            return Object.isNull(obj.autoExpand, true);
        }
        Me.Handlers.ReadViewIco = q.Handlers.ReadViewIco = function (obj) {
            ///<summary>是否显示ico前置类型图标</summary>
            ///<returns type="Boolean"><returns>
            return Object.isNull(obj.viewIco, true); ;
        }
        //事件响应
        //单击
        q.Handlers.NodeClick = function (e) {
            var node = this.TreeBinderNode;
            q.Info.LastClickNode = node;
            q.Info.LastClickNodeData = node.Bind.ViewData;
            q.Events.NodeTextClicked();
        }
        //双击
        q.Handlers.NodeDblClick = function (e) {
            q.Events.NodeTextDblClicked();
        }
        //需要加载子节点
        q.Handlers.OnNeedLoadChilds = function (e) {
            var node = this;
            if (!String) node = vs.TreeNode.Q;
            var treeData = node.Bind.ViewData;
            var tree = q.Acts.InitNextTree(null, node, treeData, true);
            tree.View();
        }
        //绑定节点单击
        q.Handlers.BindNodeClick = function (node) {
            node.Nodes.Link.TreeBinderNode = node;
            $vs.addHandler(node.Nodes.Link, $vs.dom.Events.onclick, q.Handlers.NodeClick);
            $vs.addHandler(node.Nodes.Link, $vs.dom.Events.ondblclick, q.Handlers.NodeDblClick);
        }
        //加载本节点及直属下级节点
        q.Acts.InitNextTree = function (parentTree, treeMe, treeData, loadNextLevel) {
            if (!String) parentTree = vs.Tree.Demo;
            if (!String) treeData = q.Info.TreeData;
            var h = Me.Handlers;
            var node = treeMe;
            if (!node) {
                //取值
                //var needLoadChild = h.ReadNeedLoadChild(treeData)
                needLoadChild = (h.ReadChilds(treeData).length > 0);
                var autoExpand = h.ReadAutoExpand(treeData)
                var viewIco = h.ReadViewIco(treeData);
                var text = h.ReadText(treeData);
                var href = h.ReadHref(treeData);
                var target = h.ReadTarget(treeData);
                //进行修正
                viewIco = Object.isNullOrEmpty(viewIco, true);
                target = Object.isNull(target, q.Config.Target);
                //创建节点
                var node = vs.TreeNode.$new(needLoadChild, autoExpand, viewIco);
                node.SetLink(text, href, target);
                parentTree.AddNode(node);
                //关联事件
                q.Handlers.BindNodeClick(node);
                //关联节点与数据对象
                node.Bind.ViewData = treeData;
                //关联加载事件
                node.OnNeedLoadChilds.push(q.Handlers.OnNeedLoadChilds);
            }
            //继续添加直属子节点
            if (loadNextLevel) {
                //取子节点数据
                var childs = h.ReadChilds(treeData);
                if (!childs || childs.length == 0) return;
                //加载
                var childTree = node.CreateTree();
                for (var i = 0, count = childs.length; i < count; i++) {
                    childs[i].ParentTree = treeData;
                    q.Acts.InitNextTree(childTree, null, childs[i], false);
                }
                return childTree;
            }
        }
        q.Acts.InitTree = function () {
            var multiTree = q.Info.MultiTree = vs.MultiTree.$new(q.Nodes.MainCase);
            var topTree = multiTree.CreateTopTree();
            q.Acts.InitNextTree(topTree, null, q.Info.TreeData, true);
            //alert(topTree.Nodes.MainCase.outerHTML);
        }
        //公开    
        var baseInit = q.Init;
        Me.Init = q.Init = function () {
            baseInit();
            if (!String) treeData = q.Info.TreeData;
        }
        Me.Show = q.Acts.Show = function (mainCase, treeData) {
            ///<summary>呈现树</summary>
            q.Nodes.MainCase = mainCase;
            q.Info.TreeData = treeData;
            q.Config.Target = q.Handlers.ReadTarget(q.Info.TreeData);
            q.Acts.InitTree();
            q.Info.MultiTree.View();
            q.Info.LastClickNode;
            q.Info.LastClickNodeData
        }
        Me.GetLastClickNode = q.Acts.GetLastClickNode = function () {
            ///<summary>读取最后单击的树节点</summary>
            ///<returns type="vs.TreeNode.Type"></returns>
            return q.Info.LastClickNode;
        }
        Me.GetLastClickNodeData = q.Acts.GetLastClickNodeData = function () {
            ///<summary>读取最后单击的树节点关联的数据对象</summary>
            ///<returns type="Object"></returns>
            return q.Info.LastClickNodeData;
        }
    } 
}
$vs.initType(vsClass);
vsClass.$new = function () {
    ///<returns type="vs.TreeBinder.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="vs_window.js" />
vsClass = vs.MessageBox = function () {
    var q = $vs.inherit(this, arguments, vs.Window);
    if ($vs.designMode) q = vs.Window.Q;

    var nodes = q.Nodes;
    var dom = $vs.dom;
    var doc = $vs.doc;
    //
    nodes.MessagePanel = dom.Div;

    Me.Init = q.Acts.Load = function () {
        //add nodes

        q.Load(q.Nodes.View, false, q.Acts.ResizeWindowWidthAndReturn(), 450);
    }
    var baseShow = q.Show;
    Me.Show = q.Acts.Show = function () {
        ///<summary>显示选择对话窗体</summary>
        baseShow();

    }
}


/// <reference path="vs_common.js" />
/// <reference path="vs.Control.js" />
/// <reference path="dom.js" />
vsClass = vs.GridView = function () {
    var q = $vs.inherit(this, arguments, vs.Control); if (!String) q = vs.Control.Q; var Me = this;
    //using
    var dom = $vs.dom;
    var doc = $vs.doc;
    var nodes = q.Nodes;
    var info = q.Info;
    var acts = q.Acts;
    var handlers = q.Handlers;
    var config = Me.Config = q.Config;
    //event
    $vs.addEvent(Me, "RowClick");
    $vs.addEvent(Me, "RowDblClick");
    $vs.addEvent(Me, "RowOpen");
    $vs.addEvent(Me, "RowEdit");
    $vs.addEvent(Me, "RowDelete");
    $vs.addEvent(Me, "RowCommand");
    //nodes
    nodes.MainCase = dom.Table;
    nodes.TopCheck = dom.CheckInput;
    nodes.CheckList = [];
    nodes.SelectedIDsHidden = dom.Input;
    //info
    info.ColumnNames = [];
    info.SelectObject = { rowIndex: 0 };
    info.EditRow = dom.TR;
    info.DeleteRow = dom.TR;
    info.DblClickedRow = dom.TR;
    info.KeyCode = "";
    info.EditColumnExisted = false;
    info.LastFocusRow = dom.TR;
    info.NoDataMessage = "没有数据";
    info.NoData = false;
    info.SelectedOKButtons = {};
    info.SelectedSingleOKButtons = {};
    //config
    config.EditColumnTitle = "";
    config.RowOverColor = vs.GridView.Config.RowOverColor; //"#EDF0F3";
    config.RowFocusColor = vs.GridView.Config.RowFocusColor; //"#C0E0E7";
    config.RowFocusOverColor = vs.GridView.Config.RowFocusOverColor; //"#E0F0F7";
    config.RowObjectKeepNew = true; //始终构造最新的对象
    config.RowSpanStart = -1; //起始合并列
    config.RowSpanEnd = -1; //结合并列
    //constructor
    var baseInit = q.Init;
    Me.Init = q.Init = function (gridViewTable, columnNames, hasHeadRow, keyCode, noDataMessage, noData) {
        //hasHeadRow not complted
        baseInit();
        if (!String) gridViewTable = dom.Table;
        if (!String) columnNames = [];
        nodes.MainCase = gridViewTable;
        info.KeyCode = keyCode;
        info.ColumnNames = columnNames;
        info.NoDataMessage = Object.isNull(noDataMessage, info.NoDataMessage);
        info.NoData = Object.isNull(noData, info.NoData);
        if (!nodes.MainCase) return;
        if (info.NoData) {
            acts.SetNoDataView();
        } else {
            window.setTimeout(function () {
                acts.Bind(); //执行完后可直接根据tr.RowObject来取得整行的列值字典
                acts.BindCheckList();
            });
        }
        nodes.SelectedIDsHidden = null;
        q.BindSelfSkin("vs_GridView");
    }
    acts.SetNoDataView = function () {
        var row0 = nodes.MainCase.rows[0];
        if (!String) row0 = dom.TR;
        var rowNext = nodes.MainCase.rows[1];
        var max = 0;
        while (rowNext != null && max < 1000) { rowNext.style.display = "none"; rowNext = nodes.MainCase.rows[rowNext.rowIndex + 1]; }
        var emptyRow = nodes.MainCase.insertRow(-1);
        var cell = emptyRow.insertCell(-1);
        cell.colSpan = (row0 == null) ? 1 : row0.cells.length;
        cell.innerHTML = info.NoDataMessage;
        cell.className = "NoData";
    }
    //private
    info.CheckedRowIndexer = {};
    info.CanNext = false; //已经有选中了
    info.CanSingleNext = false; //只选中一个
    acts.ChangeNextStepButtonState = function () {
        for (var id in info.SelectedOKButtons) {
            var button = info.SelectedOKButtons[id];
            var needChange = true;
            if (button.bindcolumn != null && button.bindcolumn != "") {
                for (var prop in info.CheckedRowIndexer) {
                    if (Object.isNullOrEmpty(prop)) continue;
                    var v = info.CheckedRowIndexer[prop][button.bindcolumn];
                    if (v && v.toLowerCase() == "false") {
                        needChange = false;
                        break;
                    }
                }
            }
            acts.ChgState(button, needChange && info.CanNext);
        }
        for (var id in info.SelectedSingleOKButtons) {
            var button = info.SelectedSingleOKButtons[id];
            var needChange = true;
            if (button.bindcolumn != null && button.bindcolumn != "") {
                for (var prop in info.CheckedRowIndexer) {
                    if (Object.isNullOrEmpty(prop)) continue;
                    var v = info.CheckedRowIndexer[prop][button.bindcolumn];
                    if (v && v.toLowerCase() == "false") {
                        needChange = false;
                        break;
                    }
                }
            }
            var canSingleNext = needChange && info.CanSingleNext;
            acts.ChgState(button, canSingleNext);
        }
    }
    acts.ChgState = function (button, enable) {
        if (button.tagName == "INPUT" || button.tagName == "BUTTON") {
            button.disabled = !enable;
        } else if (button.tagName == "A") {
            if (enable) {
                button.style.display = button.SaveDisplay;
                button.SaveSpan.style.display = "none";
            } else {
                button.style.display = "none";
                button.SaveSpan.style.display = button.SaveDisplay;
            }
        } else {
            with (button.style) {
                filter = enable ? "" : "alpha(opacity=40)";
                opacity = (enable ? 1 : 0.4);
            }
        }
    }
    acts.SaveSelectedIDs = function () {
        var keyArr = [];
        for (var prop in info.CheckedRowIndexer) {
            if (Object.isNullOrEmpty(prop)) continue;
            keyArr.push(prop);
        }
        info.CanNext = (keyArr.length != 0);
        info.CanSingleNext = (keyArr.length == 1);
        acts.ChangeNextStepButtonState();
        nodes.SelectedIDsHidden.value = keyArr.join("\r\n");
        //window.status = nodes.SelectedIDsHidden.value;
    }
    acts.BindSelectedIDsHidden = function (idsHiddenInput) {
        nodes.SelectedIDsHidden = idsHiddenInput;
    }
    acts.BindCheckList = function () {
        var topCheck = nodes.MainCase.rows[0].getElementsByTagName("input")[0];
        if (topCheck == null) return;
        if (!String) topCheck = dom.CheckInput;
        handlers.ChgGroup = function (e) {
            var type = Object.isNullOrEmpty(this.type, "").toLowerCase();
            if (this.checked) {
                if (type == "radio") info.CheckedRowIndexer = {};
                var allChecked = true;
                var checkList = nodes.CheckList;
                for (var i = 0, listCount = checkList.length; i < listCount; i++) {
                    if (!checkList[i].checked) {
                        allChecked = false;
                        break;
                    }
                }
                if (type != "radio" && allChecked) nodes.TopCheck.checked = true;
                info.CheckedRowIndexer[this.KeyValue] = this.DataObject;
            } else {
                nodes.TopCheck.checked = false;
                if (info.CheckedRowIndexer[this.KeyValue] != null) delete (info.CheckedRowIndexer[this.KeyValue]);
            }
            acts.SaveSelectedIDs();
        }
        handlers.ChgCheck = function (e) {
            var checked = this.checked;
            var type = Object.isNullOrEmpty(this.type, "").toLowerCase();
            if (type == "radio") {
                info.CheckedRowIndexer = {};
                acts.SaveSelectedIDs();
                return;
            }
            var checkList = nodes.CheckList;
            if (!checked) info.CheckedRowIndexer = {};
            for (var i = 0, listCount = checkList.length; i < listCount; i++) {
                checkList[i].checked = checked;
                if (checked) {
                    info.CheckedRowIndexer[checkList[i].KeyValue] = checkList[i].DataObject;
                }
            }
            acts.SaveSelectedIDs();

        }
        var type = Object.isNullOrEmpty(topCheck.type, "").toLowerCase();
        if (type == "checkbox" || type == "radio") {
            $vs.addHandler(topCheck, dom.Events.onclick, handlers.ChgCheck);
            nodes.TopCheck = topCheck;
            nodes.CheckList = [];
            var rows = nodes.MainCase.rows;
            for (var i = 1, rowsCount = rows.length; i < rowsCount; i++) {
                var checkItem = rows[i].getElementsByTagName("input")[0];
                if (checkItem) {
                    nodes.CheckList.push(checkItem);
                    var obj = acts.ReadRowObject(rows[i]);
                    checkItem.KeyValue = obj[info.KeyCode];
                    checkItem.DataObject = obj;
                    if (checkItem.checked) info.CheckedRowIndexer[checkItem.KeyValue] = checkItem.DataObject;
                    $vs.addHandler(checkItem, dom.Events.onclick, handlers.ChgGroup);
                }
            }
            acts.SaveSelectedIDs();
        }
    }
    handlers.ToDel = function (event) {
        if (!window.confirm("确认要删除吗？")) return false;
        info.DeleteRow = this.parentNode.parentNode;
        acts.ChangeFocusRow(info.DeleteRow);
        Me.RowDelete();
        return false;
    }
    acts.CreateDelLink = function () {
        var button = dom.NewButton(dom.Blank);
        button.className = "vs_GridView_DelLink";
        $vs.addHandler(button, "click", handlers.ToDel);
        button.title = "删除";
        return button;
    }
    handlers.ToEdit = function (event) {
        info.EditRow = this.parentNode.parentNode;
        acts.ChangeFocusRow(info.EditRow);
        Me.RowEdit();
        return false;
    }
    handlers.ToRowCommand = function (event) {
        info.EditRow = this.parentNode.parentNode;
        acts.ChangeFocusRow(info.EditRow);
        Me.RowCommand(this.innerHTML);
        return false;
    }
    acts.CreateEditLink = function () {
        var button = dom.NewButton(dom.Blank);
        button.className = "vs_GridView_EditLink";
        $vs.addHandler(button, "click", handlers.ToEdit);
        button.title = "编辑";
        return button;
    }
    acts.CreateCommandLink = function (innerHTML, enable) {
        var isEnable = (enable === false) ? false : true;
        if (isEnable) {
            var button = dom.NewALink(dom.DoNothingHref, "", innerHTML, false);
            button.className = "vs_GridView_BtnLink vs_GridView_" + innerHTML;
            $vs.addHandler(button, "click", handlers.ToRowCommand);
        } else {
            var button = dom.NewSpan(innerHTML, true);
            button.className = "vs_GridView_BtnLink vs_GridView_" + innerHTML;
            button.style.color = "gray";
            button.href = "";
        }
        return button;
    }
    handlers.OpenLinkClick = function (event) {
        var link = this;
        if (!String) link = dom.A;
        info.LastFocusRow = link.parentNode.parentNode;
        Me.RowOpen();
        return false;
    }
    acts.SetOpenLinkColumn = function (columnCode) {
        if (!nodes.MainCase || columnCode == "" || info.NoData) return;
        //get columnIndex
        var columnIndex = -1;
        for (var nextIndex = 0, count = info.ColumnNames.length; nextIndex < count; nextIndex++) {
            if (info.ColumnNames[nextIndex] == columnCode) {
                columnIndex = nextIndex;
                break;
            }
        }
        if (columnIndex < 0 || columnIndex >= info.ColumnNames.length) return;
        //set
        var rows = nodes.MainCase.rows;
        for (var i = 1, rowsCount = rows.length; i < rowsCount; i++) {
            var row = rows[i];
            if (!String) row = dom.TR;
            var cell = row.cells[acts.GetTrueCellIndex(row, columnIndex)];
            if (!String) cell = dom.TD;
            if (cell) {
                var text = cell.innerText;
                var link = dom.NewALink("javascript:return true;", "_self", text, false);
                cell.innerHTML = "";
                cell.appendChild(link);
                $vs.addHandler(link, dom.Events.onclick, handlers.OpenLinkClick);
            }
        }
    }
    acts.AddEditColumn = function (isCanEdit, isCanDelete, commandTexts) {
        if (!nodes.MainCase || nodes.MainCase.AddedEditColumn) return;
        if (!(isCanEdit || isCanDelete || (commandTexts != null && commandTexts != "")) || info.NoData) return;
        title = Object.isNull(config.EditColumnTitle, dom.Blank);
        var rows = nodes.MainCase.rows;
        for (var i = 0, rowsCount = rows.length; i < rowsCount; i++) {
            var row = rows[i];
            var rowData = acts.ReadRowObject(row);
            if (!String) row = dom.TR;
            if (i == 0) {
                if (rows.length > 1 && rows[1].cells.length == 1) return;
                var th = dom.NewTH(row, -1, title);
                th.innerHTML = "<div>" + title + "</div><div class='vs_GridView_EditHeaderDiv' style='height:1px; overflow:hidden;'></div>";
                q.AddClass(th, "vs_GridView_EditHeader");
            } else {
                if (row.cells.length == 1) return;
                var td = dom.NewTD(row, -1, "");
                if (isCanEdit) td.appendChild(acts.CreateEditLink());
                if (isCanDelete) td.appendChild(acts.CreateDelLink());
                if (commandTexts != null && commandTexts != "") {
                    var commandArr = commandTexts.split("|");
                    for (var j = 0, count = commandArr.length; j < count; j++) {
                        var cmdText = commandArr[j];
                        var isEnable = (rowData["Enable" + cmdText] == null || rowData["Enable" + cmdText].toLowerCase() == "true")
                        td.appendChild(acts.CreateCommandLink(commandArr[j], isEnable));
                    }
                }
            }
        }
        nodes.MainCase.AddedEditColumn = true;
    }
    acts.ReadRowObject = function (tr) {
        if (tr.RowObject != null && !config.RowObjectKeepNew) return tr.RowObject;
        return acts.ReadNewRowObject(tr);
    }
    acts.ReadNewRowObject = function (tr) {
        if (!String) tr = dom.TR;
        //create Object
        var obj = info.SelectObject = { rowIndex: 0 };
        obj.rowIndex = tr.rowIndex;
        //add property
        var cells = tr.cells;
        var startRow = 0;
        if (cells.length > 1 && cells[0].getElementsByTagName('input').length > 0) {
            startRow = 1;
            q.AddClass(cells[0], "td td_checkbox");
        }
        for (var i = 0, len = cells.length; i < len; i++) { q.AddClass(cells[i], "td"); }
        if (!cells) return {};
        for (var i = 0, propCount = info.ColumnNames.length; i < propCount; i++) {
            var propertyName = info.ColumnNames[i];
            if (Object.isNullOrEmpty(propertyName)) continue;
            var cell = cells[acts.GetTrueCellIndex(tr, i)];
            if (cell == null) continue;
            obj[propertyName] = cell.innerText;
            obj["html_" + propertyName] = cells[i].innerHTML;
        }
        tr.RowObject = obj;
        return obj;
    }
    acts.ChangeFocusRow = function (newRow) {
        if (newRow.rowIndex == info.LastFocusRow.rowIndex) return;
        info.LastFocusRow.IsFocus = false;
        info.LastFocusRow.style.backgroundColor = info.LastFocusRow.style.OldBackgroundColor;
        if (newRow.style.OldBackgroundColor == null) {
            newRow.style.OldBackgroundColor = newRow.style.backgroundColor;
        }
        newRow.style.backgroundColor = config.RowFocusColor;
        newRow.IsFocus = true;
        info.LastFocusRow = newRow;
    }
    acts.ActiveTR = function (tr) {
        if (!String) tr = dom.TR;
        function onmouseover(event) {
            var me = this; if (!String) me = dom.TR;
            if (me.style.OldBackgroundColor == null) {
                me.style.OldBackgroundColor = me.style.backgroundColor;
            }
            if (info.LastFocusRow.rowIndex == me.rowIndex) {
                me.style.backgroundColor = config.RowFocusOverColor;
            } else {
                me.style.backgroundColor = config.RowOverColor;
            }
            //me.style.backgroundColor = (info.LastFocusRow.rowIndex == me.rowIndex) ? config.RowFocusOverColor : config.RowOverColor;
        }
        function onmouseout(event) {
            var me = this; if (!String) me = dom.TR;
            me.style.backgroundColor = (me.IsFocus === true) ? config.RowFocusColor : me.style.OldBackgroundColor;
        }
        function onclick(event) {
            var me = this; if (!String) me = dom.TR;
            acts.ChangeFocusRow(me);
            Me.RowClick();
        }
        function ondblclick(event) {
            var me = this;
            if (!String) me = dom.TR;
            info.DblClickedRow = me;
            Me.RowDblClick();
        }
        acts.ReadNewRowObject(tr);
        $vs.addHandler(tr, dom.Events.onmouseover, onmouseover);
        $vs.addHandler(tr, dom.Events.onmouseout, onmouseout);
        $vs.addHandler(tr, dom.Events.onclick, onclick);
        $vs.addHandler(tr, dom.Events.ondblclick, ondblclick);
    }
    //public
    Me.AddEditColumn = acts.AddEditColumn;
    Me.SetOpenLinkColumn = acts.SetOpenLinkColumn;
    Me.GetEditingRowObject = function () { return acts.ReadRowObject(info.EditRow); }
    Me.GetDeletingRowObject = function () { return acts.ReadRowObject(info.DeleteRow); }
    Me.GetDblClickedRowObject = function () { return acts.ReadRowObject(info.DblClickedRow); }
    Me.GetLastFocusedRowObject = function () { return acts.ReadRowObject(info.LastFocusRow); }
    Me.BindSelectedIDsHidden = acts.BindSelectedIDsHidden;
    //handlers
    //binder
    acts.Bind = function () {
        var rows = nodes.MainCase.rows;
        for (var i = 1, rowsCount = rows.length; i < rowsCount; i++) {
            acts.ActiveTR(rows[i]);
        }
    }
    Me.Set_RowSpan = acts.Set_RowSpan = function (startIndex, endIndex) {
        config.RowSpanStart = startIndex;
        config.RowSpanEnd = endIndex;
    }
    acts.GetTrueCellIndex = function (row, columnIndex) {
        if (config.RowSpanStart == -1 || config.RowSpanEnd == -1) return columnIndex;
        var needMove = (columnIndex >= config.RowSpanStart)
			&& row.cells[config.RowSpanStart]
			&& (row.cells[config.RowSpanStart].className.indexOf('rowspan') == -1)
        return needMove ? columnIndex - (config.RowSpanEnd - config.RowSpanStart + 1) : columnIndex;
    }
    handlers.SelectedButton_NewClick = function (event) {
        if (!info.CanNext) return false;
        try { this.SaveOnclick.apply(this, [event]); } catch (e) { }
    }
    handlers.SingleSelectedButton_NewClick = function (event) {
        if (!info.CanSingleNext) return false;
        try { this.SaveOnclick.apply(this, [event]); } catch (e) { }
    }
    Me.BindSelectedButton = acts.BindSelectedButton = function (buttonID) {
        var button = document.getElementById(buttonID);
        if (button) {
            if (button.tagName == "INPUT" || button.tagName == "BUTTON") {
            } else if (button.tagName == "A") {
                var span = dom.NewSpan(button.innerText, true);
                span.style.display = "none";
                span.style.color = "#BBBBBB";
                button.parentNode.insertBefore(span, button);
                button.SaveDisplay = button.style.display;
                button.SaveSpan = span;
            } else {
                //重新锁定单击事件
                button.SaveOnclick = button.onclick;
                $vs.addHandler(button, dom.Events.onclick, handlers.SelectedButton_NewClick);
            }
            //记住关联关系
            info.SelectedOKButtons[buttonID] = button;
        }
        acts.ChangeNextStepButtonState();
    }
    Me.BindSingleSelectedButton = acts.BindSingleSelectedButton = function (buttonID) {
        var button = document.getElementById(buttonID);
        if (button) {
            if (button.tagName == "INPUT" || button.tagName == "BUTTON") {
            } else if (button.tagName == "A") {
                var span = dom.NewSpan(button.innerText, true);
                span.style.display = "none";
                span.style.color = "#BBBBBB";
                button.parentNode.insertBefore(span, button);
                button.SaveDisplay = button.style.display;
                button.SaveSpan = span;
            } else {
                //重新锁定单击事件
                button.SaveOnclick = button.onclick;
                $vs.addHandler(button, dom.Events.onclick, handlers.SingleSelectedButton_NewClick);
            }
            //记住关联关系
            info.SelectedSingleOKButtons[buttonID] = button;
        }
        acts.ChangeNextStepButtonState();
    }
}
vs.GridView.Config = { RowOverColor: "#EDF0F3", RowFocusColor: "#C0E0E7", RowFocusOverColor: "#E0F0F7" }
$vs.initType(vsClass);
vsClass.$new = function (gridViewTable, columnNames) {
    ///<param name="gridViewTable">表格</param>
    ///<param name="columnNames">各列对应属性名的数组，非数据列，请使用null或空字符串代替</param>
    ///<returns type="vs.GridView.Type"></returns>
    return this.New.apply(this, arguments);
}
vs.GridViewBinder = new (function () {
    var Me = this;
    Me.Bind = function (args) {
        var doc = $vs.doc;
        var grid = window[args.windowID] = vs.GridView.$new(doc.GetTable(args.gridViewClientID), args.columnCodes
		, args.hasHeaderRow, args.keyCode, args.noDataMessage, args.noData);
        grid.Config.EditColumnTitle = args.editColumnTitle;
        grid.AddEditColumn(args.isCanEdit, args.isCanDelete, args.commandTexts);
        grid.Set_RowSpan(args.rowSpanStart, args.rowSpanEnd);
        grid.SetOpenLinkColumn(args.openCode);
        grid.BindSelectedIDsHidden(args.selectedIDValueHidden_ClientIDNode);
        var edit = function () {
            var d = grid.GetLastFocusedRowObject();
            var key = d[args.keyCode];
            var type = args.postTypeEdit;
            args.postBackHandler.apply(window, [type, key]);
            return false;
        }
        var RowDel = function () {
            var d = grid.GetLastFocusedRowObject();
            var key = d[args.keyCode];
            var type = args.postTypeDel;
            args.postBackHandler.apply(window, [type, key]);
            return false;
        }
        var open = function () {
            var d = grid.GetLastFocusedRowObject();
            var key = d[args.keyCode];
            var type = args.postTypeOpen;
            args.postBackHandler.apply(window, [type, key]);
            return false;
        }
        var rowCommand = function (commandText) {
            var d = grid.GetLastFocusedRowObject();
            var key = d[args.keyCode];
            var type = args.postTypeRowCommand;
            args.commandPostBackHandler.apply(window, [type, key, commandText]);
            return false;
        }
        grid.OnRowEdit.push(edit);
        if (args.dblClickAutoAttachOpen) grid.OnRowDblClick.push(open);
        grid.OnRowOpen.push(open);
        grid.OnRowDelete.push(RowDel);
        grid.OnRowCommand.push(rowCommand);
        with (grid.Config) {
            RowOverColor = args.rowOverColor;
            RowFocusColor = args.rowFocusColor;
            RowFocusOverColor = args.RowFocusOverColor;
        }
    }
})();
/// <reference path="vs_common.js" />
/// <reference path="vs_window.js" />

vsClass = vs.Calender = function () {
    with ($vs) {
        var q = inherit(this, arguments, vs.Layer);
        if (!String) q = vs.Layer.Q;
        var Me = this;

        addEvent(Me, "Selected");
        q.Events.AttachSelected = Me.Selected;

        q.Nodes.TitleCase = dom.Div;
        q.Nodes.WeekCase = dom.Div;
        q.Nodes.DayCase = dom.Div;

        q.Nodes.PrevMonth = dom.Span;
        q.Nodes.MonthView = dom.Span;
        q.Nodes.NextMonth = dom.Span;

        q.Nodes.WeekViews = [];
        q.Nodes.DayViews = []

        q.Config.WeekDayTags = ["日", "一", "二", "三", "四", "五", "六"];
        q.Config.DayColor = "#222222"; //"#444444";
        q.Config.RestDayColor = "red";
        q.Config.GrayDayColor = "#777777";
        q.Config.OverBgColor = "#CAE4EE";
        q.Info.DateNow = new Date();
        q.Info.AllDateArray = [];
        q.Info.MonthOfNow = 0;
        q.Info.LastDateNowView = null;

        q.Acts.CreateAllDateArray = function (date) {
            if (!String) date = new Date();
            q.Info.DateNow = date;
            q.Info.MonthOfNow = date.getMonth();
            var monthFirstDay = new Date(date.getFullYear(), date.getMonth(), 1);
            var weekDay = monthFirstDay.getDay();
            monthFirstDay.setDate(-weekDay);
            var startDate = monthFirstDay;
            q.Info.AllDateArray = [];
            for (var i = 0; i < 42; i++) {
                startDate.setDate(startDate.getDate() + 1);
                var next = startDate;
                var newDate = new Date(next.getFullYear(), next.getMonth(), next.getDate());
                q.Info.AllDateArray.push(newDate);
            }
        }
        q.Acts.SetDateNow = function (daySpan) {
            if (q.Info.LastDateNowView) {
                q.Info.LastDateNowView.style.backgroundColor = "";
                q.Info.LastDateNowView.style.backgroundColorBak = null;
            }
            daySpan.style.backgroundColor = "#BAD4DE";
            daySpan.style.backgroundColorBak = "#BAD4DE";
            q.Info.LastDateNowView = daySpan;
            q.Info.DateNow = daySpan.DateValue;
        }

        q.Acts.AttachMouseEvent = function (daySpan) {
            var over = function () {
                if (!this.IsMonthNow) return;
                this.style.backgroundColor = q.Config.OverBgColor;
            }
            var out = function () {
                if (!this.IsMonthNow) return;
                var bak = this.style.backgroundColorBak;
                this.style.backgroundColor = (bak) ? bak : "";

            }
            var click = function () {
                if (!this.IsMonthNow) return;
                q.Events.AttachSelected(Me, this.DateValue);
                q.Acts.SetDateNow(this);
            }
            daySpan.onmouseover = over;
            daySpan.onmouseout = out;
            daySpan.onclick = click;
        }

        q.Acts.ViewDays = function () {
            var monthOfNow = q.Info.MonthOfNow;
            q.Nodes.MonthView.innerHTML = q.Info.DateNow.format("yyyy年M月");
            for (var i = 0; i < 42; i++) {
                var date = q.Info.AllDateArray[i];
                if (!String) date = new Date();
                var daySpan = q.Nodes.DayViews[i];
                daySpan.innerHTML = date.getDate();
                daySpan.DateValue = date;
                if (date.getMonth() == monthOfNow) {
                    daySpan.style.color = (i % 7 == 0 || (i + 1) % 7 == 0) ? q.Config.RestDayColor : q.Config.DayColor;
                    daySpan.IsMonthNow = true;
                } else {
                    daySpan.style.color = q.Config.GrayDayColor;
                    daySpan.IsMonthNow = false;
                }
                if (date.format("yyyyMMdd") == q.Info.DateNow.format("yyyyMMdd")) {
                    q.Acts.SetDateNow(daySpan);
                } else {
                    daySpan.style.backgroundColor = "";
                }
            }
        }

        var baseInit = q.Init;
        Me.Init = q.Init = function () {
            baseInit(false);
            var isInlineBlock = true;
            var today = new Date();
            with (q.Nodes) {
                //MainCase = dom.NewDiv();
                //document.body.appendChild(MainCase);
                MainCase.style.position = "absolute";

                TitleCase = dom.NewDiv();
                WeekCase = dom.NewDiv();
                DayCase = dom.NewDiv();
                with (MainCase) {
                    appendChild(TitleCase); appendChild(WeekCase); appendChild(DayCase);
                }
            }
            with (q.Nodes) {
                PrevMonth = dom.NewSpan("&lt;", isInlineBlock);
                MonthView = dom.NewSpan(today.format("yyyy年MM月"), isInlineBlock);
                NextMonth = dom.NewSpan("&gt;", isInlineBlock);
                with (TitleCase) {
                    appendChild(PrevMonth); appendChild(MonthView); appendChild(NextMonth);
                }
            }
            with (q.Nodes) {
                //Create WeekView
                for (var weekIndex = 0; weekIndex < 7; weekIndex++) {
                    var weekSpan = dom.NewSpan(q.Config.WeekDayTags[weekIndex], isInlineBlock);
                    WeekCase.appendChild(weekSpan);
                    WeekViews.push(weekSpan);
                }
            }
            with (q.Nodes) {
                //Create DayView
                for (var rowIndex = 0; rowIndex < 6; rowIndex++) {
                    for (var colIndex = 0; colIndex < 7; colIndex++) {
                        var daySpan = dom.NewSpan(dom.Blank, isInlineBlock);
                        DayCase.appendChild(daySpan);
                        q.Acts.AttachMouseEvent(daySpan);
                        DayViews.push(daySpan);
                    }
                    var lineDiv = dom.NewDiv("");
                    lineDiv.style.clear = "both";
                    lineDiv.style.height = "1px";
                    lineDiv.style.overflow = "hidden";
                    DayCase.appendChild(lineDiv);
                }
            }
            with (q.Nodes) {
                //显示当前日期
                q.Acts.CreateAllDateArray(today);
                q.Acts.ViewDays();
                q.BindSelfSkin("vs_Calender");
            }
            q.AttachEvent();
        }
        q.Acts.MoveMonth = function (monthMove) {
            var oldDate = q.Info.DateNow.getDate();
            q.Info.DateNow.setMonth(q.Info.DateNow.getMonth() + monthMove);
            var newDate = q.Info.DateNow.getDate();
            if (oldDate != newDate) {
                var newTimeValue = q.Info.DateNow.getTime() - newDate * 24 * 60 * 60 * 1000;
                q.Info.DateNow = new Date(newTimeValue);
            }
            q.Acts.CreateAllDateArray(q.Info.DateNow);
            q.Acts.ViewDays();
        }
        q.Handlers.Show = function (dateValue) {
            window.clearTimeout(q.Info.HideTimer);
            q.Nodes.MainCase.style.display = "inline";
            q.ReSetLayer();
            q.Acts.CreateAllDateArray(dateValue);
            q.Acts.ViewDays();
        }
        Me.Show = q.Acts.Show = function (dateValue) {
            window.clearTimeout(q.Info.HideTimer);
            window.setTimeout(function () {
                q.Handlers.Show(dateValue);
            }, 10);
        }
        q.Info.HideTimer = null;
        Me.Hide = q.Acts.Hide = function () {
            q.Nodes.MainCase.style.display = "none";
        }
        Me.TryHide = q.Acts.TryHide = function (milliSeconds) {
            window.clearTimeout(q.Info.HideTimer);
            milliSeconds = Object.isNullOrEmpty(milliSeconds, 200);
            q.Info.HideTimer = window.setTimeout(q.Acts.Hide, milliSeconds);
        }
        q.AttachEvent = function () {
            with (q.Nodes.PrevMonth) {
                onmouseover = function () {
                    this.style.backgroundColor = q.Config.OverBgColor;
                }
                onmouseout = function () {
                    this.style.backgroundColor = "";
                }
                onclick = function () { q.Acts.MoveMonth(-1); }
            }
            with (q.Nodes.NextMonth) {
                onmouseover = function () {
                    this.style.backgroundColor = q.Config.OverBgColor;
                }
                onmouseout = function () {
                    this.style.backgroundColor = "";
                }
                onclick = function () { q.Acts.MoveMonth(1); }
            }
            //        var keepView = function(){
            //            q.Nodes.MainCase.style.display = "block";
            //        }
            with (q.Nodes.MainCase) {
                onclick = function () {
                    q.Acts.TryHide(3000);
                }
                //            onmouseover = function(){
                //                q.Acts.TryHide(200);
                //            }
                //            onmouseout = function(){
                //                q.Acts.TryHide(200);
                //            }
            }
        }
    }
}
$vs.initType(vsClass);

vsClass.$new = function () {
    ///<returns type="vs.Calender.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="vs.Calender.js" />
/// <reference path="vs.Validater.js" />
/// <reference path="dom.js" />
vsClass = vs.CalenderBinder = function () {
    with ($vs) {
        var q = $vs.inherit(this, arguments, vs.Object);
        if (!String) q = vs.Object.Q;
        var Me = this;
        var designMode = $vs.designMode;

        if (!q.Static.Private1) {
            q.Static.Private1 = new function () {
                var S = this;
                var Calender;
                if (!String) Calender = vs.Calender.Demo;
                S.LastFocusInput = dom.Input;
                S.CreateCalender = function () {
                    if (Calender == null || Object.isNullOrEmpty(Calender.Nodes.MainCase.innerHTML)) Calender = vs.Calender.$new();
                    Calender.Hide();
                    Calender.OnSelected.push(function (calender, dateValue) {
                        //Calender.TryHide(3000);
                        Calender.Hide();
                        if (S.LastFocusInput) {
                            var input = S.LastFocusInput;
                            if (input.Validater == null) {
                                input.RealValue = Date.ParseEnyFormat(input.value);
                            }
                            var oldDate = input.RealValue;
                            if (!String) oldDate = new Date();
                            if (!String) dateValue = new Date();
                            if (oldDate == null) {
                                oldDate = dateValue;
                            } else {
                                oldDate.setFullYear(dateValue.getFullYear(), dateValue.getMonth(), dateValue.getDate());
                            }
                            S.LastFocusInput.value = oldDate.format(input.DateTimeFormat);
                            //if(S.LastFocusInput.onchange)S.LastFocusInput.onchange(S.LastFocusInput);
                        }
                    });
                    if ($vs.doc.GetTextInput("v")) { $vs.doc.GetTextInput("v").value += Calender.Nodes.MainCase.outerHTML; }
                }
                S.GetCalender = function () {
                    if (Calender == null || Object.isNullOrEmpty(Calender.Nodes.MainCase.innerHTML)) Calender = vs.Calender.$new();
                    return Calender;
                }
            }
        }
        q.Config.DefaultDateTimeFormat = "yyyy-MM-dd";

        q.Handlers.ShowCalender = function (input) {
            if (!String) input = dom.Input;
            if (designMode) input = $vs.dom.Input;
            if (input.readOnly) return;
            //触发数据验证
            if (input.Validater) input.Validater.Run();
            //取日历控件
            var calender = q.Static.Private1.GetCalender();
            var span = dom.NewSpan("");
            input.parentNode.insertBefore(span, input);
            span.swapNode(calender.Nodes.MainCase);
            var text = input.value;
            var dateNow;
            if (input.Validater == null) {
                input.RealValue = Date.ParseEnyFormat(text);
            }
            if (Object.isNullOrEmpty(text) || input.RealValue == null) {
                dateNow = new Date();
            } else {
                dateNow = input.RealValue;
            }
            calender.Show(dateNow);
            q.Static.Private1.LastFocusInput = input;
        }
        q.Handlers.OnFocus = function () {
            var input = this;
            q.Handlers.ShowCalender(input);
        }
        q.Handlers.OnBlur = function (e) {
            var calender = q.Static.Private1.GetCalender();
            var parentNode = e.srcElement;
            var targetNode = calender.Nodes.MainCase;
            while (parentNode != null) {
                if (parentNode == targetNode) return;
                parentNode = parentNode.parentNode;
            }
            calender.TryHide();
            //q.Static.Private1.LastFocusInput = null;
        }
        Me.BindToTextInput = q.Acts.BindToTextInput = function (textInputArray, dateFormat, needCheck, checkFirst) {
            q.Static.Private1.CreateCalender();
            dateFormat = Object.isNullOrEmpty(dateFormat, q.Config.DefaultDateTimeFormat);
            for (var i = 0, count = textInputArray.length; i < count; i++) {
                var input = textInputArray[i];
                vs.Control.AddClass(input, "vs_CalenderInput");
                $vs.addHandler(input, $vs.dom.Events.onfocus, q.Handlers.OnFocus);
                $vs.addHandler(input, $vs.dom.Events.onclick, q.Handlers.OnFocus);
                $vs.addHandler(input, $vs.dom.Events.onblur, q.Handlers.OnBlur);
                $vs.addHandler(document.body, $vs.dom.Events.onclick, q.Handlers.OnBlur);
                input.DateTimeFormat = dateFormat;
                if (needCheck) {
                    var valid = input.Validater = vs.Validater.$new(input);
                    valid.BindDateTime(input.DateTimeFormat, checkFirst);
                }
            }
        }
        Me.AddLoader = q.Acts.AddLoader = function (textInputArray) {
            for (var i = 0, count = textInputArray.length; i < count; i++) {
                var input = textInputArray[i];
                if (!String) input = $vs.dom.Input;
                var button = $vs.dom.NewButton("");
                button.DateInput = input;
                button.className = "vs_CalenderLoader";
                input.parentNode.insertBefore(button, input)
                button.swapNode(input);
                $vs.addHandler(button, $vs.dom.Events.onclick, function () { q.Handlers.ShowCalender(this.DateInput); return false; });
            }
        }
    }
}
$vs.initType(vsClass);
vsClass.$new = function () {
    ///<returns type="vs.CalenderBinder.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="vs.CalenderBinder.js" />
vs.CalenderBinder.DataBind = function (input, dateFormat, needCheck, checkFirst, showLoaderImage) {
    ///<param name="input">输入框</param>
    ///<param name="dateFormat">日期显示格式，同C#的DateTime类型对象的toString内的格式化字符串，如"yyyy年MM月dd日hh:mm:ss"</param>
    ///<param name="needCheck">是否做合法性检测<param>
    ///<param name="checkFirst">是否对初始值做合法性检测<param>
    ///<param name="showLoaderImage">是否显示引导图片<param>
    showLoaderImage = Object.isNull(showLoaderImage, true);
    vs.CalenderBinder.Demo.BindToTextInput([input], dateFormat, needCheck, checkFirst, showLoaderImage);
    if (showLoaderImage) {
        vs.CalenderBinder.Demo.AddLoader([input]);
    }
}
vs.CalenderBinder.DataBindPre = function (me, dateFormat, needCheck, checkFirst, showLoaderImage) {
    ///<param name="me">自身标签</param>
    ///<param name="dateFormat">日期显示格式，同C#的DateTime类型对象的toString内的格式化字符串，如"yyyy年MM月dd日hh:mm:ss"</param>
    ///<param name="needCheck">是否做合法性检测<param>
    ///<param name="checkFirst">是否对初始值做合法性检测<param>
    ///<param name="showLoaderImage">是否显示引导图片<param>
    var pre = me.previousSibling;
    while (pre != null && pre.value == null && pre.previousSibling != null) { pre = pre.previousSibling; }
    if (pre != null) vs.CalenderBinder.DataBind(pre, dateFormat, needCheck, checkFirst, showLoaderImage);
}

/// <reference path="dom_ext.js" />

/// <reference path="vs_common.js" />

/// <reference path="vs_window.js" />

/// <reference path="dom.js" />

if (typeof (eastcom) == "undefined") var eastcom = {};

/// <reference path="eastcom.common.js" />
/// <reference path="vs.TreeBinder.js" />

window.eastcomClass = eastcom.OrganizeTreeView = function () {
    var q = $vs.inherit(this, arguments, vs.Control);
    if (!String) q = vs.Control.Q;

    var Me = this;
    $vs.addEvent(Me, "Clicked");
    $vs.addEvent(Me, "DblClicked");
    var info = q.Info;
    q.Events.Clicked = function (tree) { Me.Clicked(tree); }
    q.Events.DblClicked = function (tree) { Me.DblClicked(tree); }

    q.Info.TreeBinder = vs.TreeBinder.Demo;
    q.Info.TreeData = null;
    q.Info.DataProvider = {};
    info.LoadDataOK = false;
    q.Demos.TreeDataObject = { ID: "", Name: "", ParentID: "", Parent: {} };
    q.Info.Childs = {};
    Me.AvailTree = q.Info.AvailTree = {};

    q.Acts.InitChildsAtIndexer = function (treeData, indexer) {
        var childs = {};
        for (var id in indexer) {
            var tree = treeData[id];
            if (!String) tree = q.Demos.TreeDataObject;
            //关联子节点集合
            var parentID = tree.ParentID;
            if (childs[parentID] == null) {
                childs[parentID] = [tree];
            } else {
                childs[parentID].push(tree);
            }
            //关联父节点
            tree.Parent = treeData[parentID];
        }
        return childs;
    }
    q.Acts.InitChilds = function (treeData, organizationIDLimit) {
        var childs = q.Info.Childs;
        if (organizationIDLimit.length == 0) {
            q.Info.Childs = q.Acts.InitChildsAtIndexer(treeData, treeData);
        } else {
            var allChildIndexer = q.Acts.InitChildsAtIndexer(treeData, treeData);
            var indexer = {};
            for (var i = 0, count = organizationIDLimit.length; i < count; i++) {
                indexer[organizationIDLimit[i]] = true;
            }
            //向上追溯
            q.Acts.ToUpTree(treeData, indexer, 0);
            //向下追溯
            q.Acts.ToDownTree(treeData, indexer, allChildIndexer, 0);
        }
    }
    var info = q.Info;
    Me.Handlers = {};

    q.Acts.ToUpTree = function (treeData, indexer, upStep) {
        var childs = q.Info.Childs;
        var parentIDIndexer = {};
        if (upStep > 10) return;
        for (var id in indexer) {
            var tree = treeData[id];
            if (!tree) continue;
            if ($vs.designMode) tree = q.Demos.TreeDataObject;
            //上级节点不计为有效可用节点
            if (upStep == 0) info.AvailTree[tree.ID] = tree;
            var parentID = tree.ParentID;
            if (parentID != "") parentIDIndexer[parentID] = true;
            if (childs[parentID] == null) {
                childs[parentID] = [tree];
            } else {
                childs[parentID].push(tree);
            }
            //关联父节点
            tree.Parent = treeData[parentID];
        }
        q.Acts.ToUpTree(treeData, parentIDIndexer, upStep + 1);
    }

    q.Acts.ToDownTree = function (treeData, indexer, allChildIndexer, downStep) {
        var childs = q.Info.Childs;
        var newChildIDIndexer = {};
        if (downStep > 10) return;
        for (var parentID in indexer) {
            var newChilds = allChildIndexer[parentID];
            if (newChilds == null) continue;
            for (var i = 0, count = newChilds.length; i < count; i++) {
                var tree = newChilds[i];
                if ($vs.designMode) tree = q.Demos.TreeDataObject;
                Me.AvailTree[tree.ID] = true;
                if (childs[parentID] == null) {
                    childs[parentID] = [tree];
                } else {
                    childs[parentID].push(tree);
                }
                newChildIDIndexer[tree.ID] = true;
                //关联父节点
                tree.Parent = treeData[parentID];
            }
        }
        q.Acts.ToDownTree(treeData, newChildIDIndexer, allChildIndexer, downStep + 1);
    }

    q.Handlers.ReadTreeOK = function (treeData, organizationIDLimit) {
        info.LoadDataOK = true;
        q.Info.TreeData = treeData;
        q.Acts.InitChilds(treeData, organizationIDLimit);
        var treeBinder = q.Info.TreeBinder;
        //指定数据转换句柄
        treeBinder.Handlers.ReadText = function (tree) {
            if (!String) tree = q.Demos.TreeDataObject;
            return tree.Name;
        }
        treeBinder.Handlers.ReadChilds = function (tree) {
            if (!String) tree = q.Demos.TreeDataObject;
            return info.Childs[tree.ID] || [];
        }
        //显示
        treeBinder.Show(q.Nodes.MainCase, q.Info.TreeData["99999"]);
    }
    q.Handlers.NodeClicked = function () {
        q.Events.Clicked(q.Info.TreeBinder.GetLastClickNodeData());
    }
    q.Handlers.NodeDblClicked = function () {
        q.Events.DblClicked(q.Info.TreeBinder.GetLastClickNodeData());
    }

    var baseInit = q.Init;
    Me.Init = q.Init = function (dataProvider) {
        baseInit();
        q.Info.DataProvider = dataProvider;
        var treeBinder = q.Info.TreeBinder = vs.TreeBinder.$new();
        AttachEvent();
    }
    Me.Show = q.Acts.Show = function (mainCase, organizationIDLimit) {
        ///<summary>开始向服务器端主请求数据，并在得到数据后直接呈现树</summary>
        q.Nodes.MainCase = mainCase;
        mainCase.innerHTML = "";
        q.Info.DataProvider.NeedTree("-1", q.Handlers.ReadTreeOK, organizationIDLimit);
    }
    Me.TestReloadShow = q.Acts.TestReloadShow = function (organizationIDLimit) {
        if (!info.LoadDataOK) {
            q.Info.DataProvider.NeedTree("-1", q.Handlers.ReadTreeOK, organizationIDLimit);
        }
    }

    var AttachEvent = q.AttachEvent = function () {
        q.Info.TreeBinder.OnNodeTextClicked.push(q.Handlers.NodeClicked);
        q.Info.TreeBinder.OnNodeTextDblClicked.push(q.Handlers.NodeDblClicked);
    }
}
$vs.initType(window.eastcomClass);

window.eastcomClass.$new = function (dataProvider) {
    ///<param name="mainCase">呈现树的容器</param>
    ///<returns type="eastcom.OrganizeTreeView.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="eastcom.OrganizeTreeView.js" />

//××××××××××××××××××
// ┌－－－－－－－－－－－－－┐
// ｜   组  ｜   成   ｜   选  ｜
// ｜   织  ｜   员   ｜   择  ｜
// ｜   树  ｜   框   ｜   框  ｜
// ｜       ｜        ｜       ｜
// ｜－－－－－－－－－－－－－｜
// ｜   ＝确认＝    ＝取消＝   ｜
// └－－－－－－－－－－－－－┘
//××××××××××××××××××
eastcomClass = eastcom.OrganizeTreeViewWindow = function () {
    var q = $vs.inherit(this, arguments, vs.Window);
    if (!String) q = vs.Window.Q;

    var Me = this;
    var config = q.Config;
    var info = q.Info;
    var dom = $vs.dom, doc = $vs.doc;
    var nodes = q.Nodes;
    q.Config.TreeMemberViewTitle = "请选择..";
    q.Config.ResetSelectedMemberTitle = "原来所选";
    q.Config.SelectedMemberViewTitle = "当前已选成员({0})";
    q.Config.SelectTypeCode = { MultiPeople: 0, SinglePeople: 1, MultiOrg: 2, SingleOrg: 3 };

    q.Info.IDContainer = dom.Input;
    q.Info.NameContainer = dom.Select;
    q.Info.CurrentSelectTypeCode = q.Config.SelectTypeCode.MultiPeople;
    q.Info.NeedReload = false;
    q.Info.OrganizationIDLimit = [];
    q.Info.HaveOrganizationLimit = false;
    q.Info.RequestContext = "default";
    q.Info.OrganizeTree = eastcom.OrganizeTreeView.Demo;
    q.Info.OrganizeTreeLoaded = false;
    q.Info.DataProvider = {}

    q.Nodes.View = dom.Span;
    q.Nodes.TreeView = dom.TD;
    q.Nodes.TreeMemberView = dom.TD;
    q.Nodes.TreeMemberSelecter = dom.Select;
    q.Nodes.TreeMemberSelecterMore = dom.Div;
    q.Nodes.TreeMemberSelecterRemoveButton = dom.Button;
    q.Nodes.SelectedMemberView = dom.TD;
    q.Nodes.SelectedMemberSelecter = dom.Select;

    q.Nodes.TreeMemberViewTitle = dom.Span;
    q.Nodes.SelectedMemberViewTitle = dom.Span;

    q.Nodes.MoveGroupView = dom.TD;
    q.Nodes.MoveAdd = dom.Button;
    q.Nodes.MoveDel = dom.Button;
    q.Nodes.MoveAddAll = dom.Button;
    q.Nodes.MoveDelAll = dom.Button;

    q.Nodes.ButtonLineSplit = dom.HR;
    q.Nodes.ButtonLineView = dom.Div;
    q.Nodes.ButtonOK = dom.Button;
    q.Nodes.ButtonCancel = dom.Button;

    q.Demos.PeopleData = { ID: "", UserID: "", Name: "", OrgID: "" };
    q.Acts.ResizeWindowWidthAndReturn = function () {
        var totalWidth = 660;
        var width = totalWidth;
        var nodes = q.Nodes;
        switch (info.CurrentSelectTypeCode) {
            case config.SelectTypeCode.SinglePeople:
            case config.SelectTypeCode.MultiOrg:
                width = totalWidth - 220;
                nodes.MoveGroupView.style.display = "none";
                nodes.SelectedMemberView.style.display = "none";
                break;
            case config.SelectTypeCode.SingleOrg:
                width = 295;
                nodes.MoveGroupView.style.display = "none";
                nodes.SelectedMemberView.style.display = "none";
                nodes.TreeMemberView.style.display = "none";
                break;
        }
        return width;
    }

    Me.Init = q.Acts.Load = function (dataProvider, idContainer, nameContainer, selectTypeCode, needReload, organizationIDLimit, context) {
        ///<summary>实例化窗体</summary>
        ///<param name="idContainer">结果ID存储容器</param>
        ///<param name="nameContainer">结果Name存储容器</param>
        ///<param name="needReload">用户选择完毕后是否需要刷新整个页面</param>
        ///<param name="context">请求标识,用户区分不同按钮的查询请求</param>
        q.Info.DataProvider = dataProvider;
        q.Info.IDContainer = idContainer;
        q.Info.NameContainer = nameContainer;
        if (selectTypeCode != null) info.CurrentSelectTypeCode = selectTypeCode;
        q.Info.NeedReload = needReload;
        q.Info.OrganizationIDLimit = organizationIDLimit;
        q.Info.HaveOrganizationLimit = (q.Info.OrganizationIDLimit.length > 0);
        q.Info.RequestContext = context;
        with (q.Nodes) {
            View = dom.NewSpan();
            idContainer.parentNode.insertBefore(View, idContainer);
            var table = dom.NewTable(); table.border = 0; table.cellPadding = 0; table.cellSpacing = 0; table.style.width = "100%";
            View.appendChild(table);
            var row = table.insertRow(-1);

            var treeViewZone = row.insertCell(-1); treeViewZone.vAlign = "top";
            treeViewZone.innerHTML = "";
            TreeView = dom.NewDiv();
            treeViewZone.appendChild(TreeView);
            TreeMemberView = row.insertCell(-1); TreeMemberView.vAlign = "top";
            MoveGroupView = row.insertCell(-1); MoveGroupView.vAlign = "top";
            SelectedMemberView = row.insertCell(-1); SelectedMemberView.vAlign = "top";
            ButtonLineView = dom.NewDiv("");

            TreeMemberViewTitle = dom.NewDiv(q.Config.TreeMemberViewTitle);
            SelectedMemberViewTitle = dom.NewDiv(String.format(q.Config.SelectedMemberViewTitle, 0));

            TreeMemberSelecter = dom.NewSelect(true);
            TreeMemberSelecter.size = 21;
            TreeMemberSelecter.multiple = (info.CurrentSelectTypeCode == config.SelectTypeCode.MultiPeople);
            SelectedMemberSelecter = dom.NewSelect(true);
            SelectedMemberSelecter.size = 21;
            ButtonLineSplit = dom.NewHR();
            ButtonOK = dom.NewButton("确认");
            ButtonCancel = dom.NewButton("取消");

            MoveAdd = dom.NewButton("追加 >"); MoveAdd.title = "追加";
            MoveAddAll = dom.NewButton("全部 >"); MoveAddAll.title = "全部追加";

            MoveDel = dom.NewButton("移除所选"); MoveDel.title = "移除";
            MoveDelAll = dom.NewButton(" 全部移除 "); MoveDelAll.title = "全部移除";

            TreeMemberSelecterRemoveButton = dom.NewButton("移除所选");

            TreeMemberSelecterMore = dom.NewDiv();
        }
        q.Load(q.Nodes.View, false, q.Acts.ResizeWindowWidthAndReturn(), 450);
        var div;
        with (q.Nodes) {
            //View.appendChild(TreeMemberView);
            //View.appendChild(MoveGroupView);
            //View.appendChild(SelectedMemberView);
            //            var clearDiv = dom.NewDiv("");
            //            clearDiv.style.clear = "both";
            //            View.appendChild(clearDiv);
            View.appendChild(ButtonLineSplit);
            View.appendChild(ButtonLineView);
            div = dom.NewDiv();
            TreeMemberView.appendChild(div);
            div.appendChild(TreeMemberViewTitle);
            div.appendChild(TreeMemberSelecter);
            var span = dom.NewSpan("<=Ctrl追加");
            TreeMemberSelecterMore.appendChild(span);
            TreeMemberSelecterMore.appendChild(TreeMemberSelecterRemoveButton);
            TreeMemberView.appendChild(TreeMemberSelecterMore);

            MoveGroupView.appendChild(MoveAdd);
            MoveGroupView.appendChild(MoveAddAll);
            //            MoveGroupView.appendChild(MoveDel);
            //            MoveGroupView.appendChild(MoveDelAll);
            div = dom.NewDiv();
            SelectedMemberView.appendChild(div);
            div.appendChild(SelectedMemberViewTitle);
            div.appendChild(SelectedMemberSelecter);
            div = dom.NewDiv();
            SelectedMemberView.appendChild(div);
            div.appendChild(MoveDel);
            div.appendChild(MoveDelAll);

            ButtonLineView.appendChild(ButtonOK);
            ButtonLineView.appendChild(ButtonCancel);

            window.setTimeout(function () {
                TreeMemberSelecter.appendChild(dom.NewOption("..", ".."));
                SelectedMemberSelecter.appendChild(dom.NewOption("..", ".."));
                window.setTimeout(function () {
                    TreeMemberSelecter.options.length = 0;
                    SelectedMemberSelecter.options.length = 0;
                }, 1)
            }, 1);
        }
        q.BindSelfSkin("eastcom_OrganizeTreeViewWindow");
        q.Info.OrganizeTree = eastcom.OrganizeTreeView.$new(info.DataProvider);
        //定制窗体
        q.SetTitle("请选择...(多选Ctrl,连选Shift)");
        q.Acts.SetMaxGoEnable(false);
        q.Acts.SetMinGoEnable(false);
        q.SetCenterStartPosition();
        //变关闭为隐藏
        $vs.removeHandler(q.Nodes.CloseViewGo, "click", q.Close);
        $vs.addHandler(q.Nodes.CloseViewGo, "click", q.Hide);
        //取消双击标题行窗口最大化
        $vs.removeHandler(q.Nodes.TitleView, "dblclick", q.Handlers.WindowMaxChg);

        AttachEvent();
    }
    q.Acts.ShowSelectedCount = function () {
        var selecter = q.Nodes.SelectedMemberSelecter;
        q.Nodes.SelectedMemberViewTitle.innerHTML = String.format(q.Config.SelectedMemberViewTitle, selecter.options.length);
    }
    q.Info.PeopleAdded = {};
    q.Acts.MoveAddPeoples = function (selectedPeoples) {
        var selecter = q.Nodes.SelectedMemberSelecter;
        var indexer = q.Info.PeopleAdded;
        for (i = 0, len = selectedPeoples.length; i < len; i++) {
            var people = selectedPeoples[i];
            if (!String) people = q.Demos.PeopleData;
            if (indexer[people.ID] != null) continue;
            var opt = $vs.dom.NewOption(people.Name, people.ID);
            opt.People = people;
            indexer[people.ID] = people;
            selecter.appendChild(opt);
        }
        q.Acts.ShowSelectedCount();
    }
    Me.ClearSelected = q.Acts.ClearSelected = function () {
        ///<summary>清除已经选择了的人员列表框</summary>
        q.Info.PeopleAdded = {};
        with (q.Nodes) {
            SelectedMemberSelecter.options.length = 0;
            TreeMemberSelecter.options.length = 0;
            TreeMemberViewTitle.innerHTML = q.Config.TreeMemberViewTitle;
        }
        q.Acts.ShowSelectedCount();
    }
    q.Handlers.ReadSelectedItemReturn = function (indexer) {
        q.Nodes.TreeMemberViewTitle.innerHTML = q.Config.ResetSelectedMemberTitle;
        q.Handlers.ViewItems(indexer, null);
        q.Handlers.MoveAddAll();
    }

    Me.ResetSelected = q.Acts.ResetSelected = function () {
        q.Acts.ClearSelected();
        if (q.Info.IDContainer.value != "") {
            if (info.CurrentSelectTypeCode == config.SelectTypeCode.MultiPeople || info.CurrentSelectTypeCode == config.SelectTypeCode.SinglePeople) {
                info.DataProvider.NeedSelectedPeoples(q.Info.IDContainer.value, q.Handlers.ReadSelectedItemReturn);
            } else {
                info.DataProvider.NeedSelectedOrganizations(q.Info.IDContainer.value, q.Handlers.ReadSelectedItemReturn);
            }
        }
    }
    var baseShow = q.Show;
    Me.Show = q.Acts.Show = function () {
        ///<summary>显示选择对话窗体</summary>
        baseShow();
        //q.Info.OrganizeTree.Show(q.Nodes.TreeView);
        window.setTimeout(function () {
            if (!q.Info.OrganizeTreeLoaded) {
                q.Info.OrganizeTree.Show(q.Nodes.TreeView, q.Info.OrganizationIDLimit);
                q.Info.OrganizeTreeLoaded = true;
            } else {
                q.Info.OrganizeTree.TestReloadShow(q.Info.OrganizationIDLimit);
            }
        }, 500);
    }
    //    Me.TestReloadShow = q.Acts.TestReloadShow = function(){
    //        q.Info.OrganizeTreeLoaded = false;
    //        window.setTimeout(function(){
    //            q.Info.OrganizeTree.TestReloadShow(q.Info.OrganizationIDLimit);
    //            q.Info.OrganizeTreeLoaded = true;
    //        },500);
    //    }
    q.Handlers.ViewItems = function (itemIndexer, context) {
        needClear = (context == null) ? true : ((context.needClear === false) ? false : true);
        var peopleArr = [];
        for (var index in itemIndexer) {
            if (itemIndexer[index].ID) peopleArr.push(itemIndexer[index]);
        }
        var tree = (context == null) ? null : context.tree;
        if (!String) tree = q.Info.OrganizeTree.Demos.TreeDataObject;
        var selecter = q.Nodes.TreeMemberSelecter;
        if (needClear) selecter.options.length = 0;
        for (var i = 0, len = peopleArr.length; i < len; i++) {
            var people = peopleArr[i];
            if (!String) people = q.Demos.PeopleData;
            var opt = $vs.dom.NewOption(people.Name, people.ID);
            opt.People = people;
            selecter.appendChild(opt);
        }
        if (tree) {
            //变化选头
            if (info.CurrentSelectTypeCode == config.SelectTypeCode.MultiPeople
                || info.CurrentSelectTypeCode == config.SelectTypeCode.SinglePeople) {
                nodes.TreeMemberViewTitle.innerHTML = String.format("{0}", tree.Name);
                q.SetStatus(String.format("{0}(ID:{1}),{2}人", tree.Name, tree.ID, selecter.options.length));
            } else {
                nodes.TreeMemberViewTitle.innerHTML = String.format("{0}{1}", "已选组织", selecter.options.length)
            }
            //同步最终选择
            if (!(info.CurrentSelectTypeCode == config.SelectTypeCode.MultiPeople)) {
                q.Handlers.MoveDelAll();
                if (info.CurrentSelectTypeCode == config.SelectTypeCode.MultiOrg || info.CurrentSelectTypeCode == config.SelectTypeCode.SingleOrg) {
                    q.Handlers.MoveAddAll();
                }
            }
        }
    }
    q.Handlers.OrganizeTree_OnClicked = function (tree) {
        if (!String) tree = q.Info.OrganizeTree.Demos.TreeDataObject;
        //是否为限制树节点
        if (tree && info.HaveOrganizationLimit && info.OrganizeTree.AvailTree[tree.ID] == null) return;
        //否则继续
        var needClear = (!(window.event && window.event.ctrlKey));
        if (info.CurrentSelectTypeCode == config.SelectTypeCode.SingleOrg) needClear = true;
        if (info.CurrentSelectTypeCode == config.SelectTypeCode.MultiPeople
            || info.CurrentSelectTypeCode == config.SelectTypeCode.SinglePeople) {
            info.DataProvider.NeedPeoplesInTree(tree.ID, q.Handlers.ViewItems, { tree: tree, needClear: needClear });
        } else {
            var indexer = {};
            indexer[tree.ID] = tree;
            q.Handlers.ViewItems(indexer, { tree: tree, needClear: needClear });
        }
    }
    q.Handlers.MoveAdd = function () {
        var arr = q.Nodes.TreeMemberSelecter.options;
        var selectedPeoples = [];
        for (var i = 0, len = arr.length; i < len; i++) {
            if (arr[i].selected) {
                selectedPeoples.push(arr[i].People);
            }
        }
        q.Acts.MoveAddPeoples(selectedPeoples);
    }
    q.Handlers.MoveDel = function () {
        var arr = q.Nodes.SelectedMemberSelecter.options;
        var indexer = q.Info.PeopleAdded;
        for (var i = 0, len = arr.length; i < len; ) {
            if (arr[i].selected) {
                var people = arr[i].People;
                if (!String) people = q.Demos.PeopleData;
                delete (indexer[people.ID]);
                arr[i].removeNode(true);
                len--;
            } else {
                i++;
            }
        }
        q.Acts.ShowSelectedCount();
    }
    q.Handlers.MoveAddAll = function () {
        var arr = q.Nodes.TreeMemberSelecter.options;
        var selectedPeoples = [];
        for (var i = 0, len = arr.length; i < len; i++) {
            selectedPeoples.push(arr[i].People);
        }
        q.Acts.MoveAddPeoples(selectedPeoples);
    }
    q.Handlers.MoveDelAll = function () {
        q.Nodes.SelectedMemberSelecter.options.length = 0;
        q.Info.PeopleAdded = {};
        q.Acts.ShowSelectedCount();
    }
    q.Handlers.SelectCompletedCallBack = function (empty, selectedPeopleIDs) {
        //暂不需要处理
    }
    q.Handlers.ButtonOK_Onclick = function () {
        var val = "", split = "";
        for (var peopleID in q.Info.PeopleAdded) {
            val += split + peopleID;
            split = ",";
        }
        q.Info.IDContainer.value = val;
        if (info.NameContainer) eastcom.OrganizeTreeViewWindow.FillList(q.Info.PeopleAdded, q.Info.NameContainer);
        //if(window.OrganizeTreeSelected)window.OrganizeTreeSelected(idArr,nameArr,q.Info.RequestContext);
        if (q.Info.NeedReload) {
            info.DataProvider.SelectCompleted(val, q.Info.RequestContext);
        } else {
            info.DataProvider.SelectCompletedCallBack(val, q.Handlers.SelectCompletedCallBack, q.Info.RequestContext);
        }
        q.SetMinView();
    }
    q.Handlers.ButtonCancel_Onclick = function () {
        q.SetMinView();
    }
    q.Handlers.TreeMemberSelecterRemove = function () {
        var selecter = nodes.TreeMemberSelecter;
        var removeNodes = [];
        for (var i = 0, count = selecter.options.length; i < count; i++) {
            var opt = selecter.options[i];
            if ($vs.designMode) opt = dom.Option;
            if (opt.selected) removeNodes.push(opt);
        }
        for (var i = 0, count = removeNodes.length; i < count; i++) {
            removeNodes[i].removeNode(true);
        }
        q.Handlers.TreeMemberSelecter_Click();
    }
    q.Acts.ViewFirstSelectTreeMember = function () {
        var options = nodes.TreeMemberSelecter.options;
        var firstSelectOption;
        for (var i = 0, optCount = options.length; i < optCount; i++) {
            if (options[i].selected) {
                firstSelectOption = options[i];
                break;
            }
        }
        if (firstSelectOption != null) q.SetStatus(String.format("{0}(ID:{1})", firstSelectOption.text, firstSelectOption.value));
    }
    q.Acts.ViewFirstSelectMember = function () {
        var options = nodes.SelectedMemberSelecter.options;
        var firstSelectOption;
        for (var i = 0, optCount = options.length; i < optCount; i++) {
            if (options[i].selected) {
                firstSelectOption = options[i];
                break;
            }
        }
        if (firstSelectOption != null) {
            var peopleData = opt.People;
            if ($vs.designMode) peopleData = q.Demos.PeopleData;

            q.SetStatus(String.format("{0}(ID:{1},组织{2})", firstSelectOption.text, firstSelectOption.value, peopleData.OrgID));
        }
    }
    q.Handlers.TreeMemberSelecter_Click = function () {
        //同步单个组织/人员选择的数据
        if (info.CurrentSelectTypeCode == config.SelectTypeCode.SinglePeople
            || info.CurrentSelectTypeCode == config.SelectTypeCode.SingleOrg) {
            q.Handlers.MoveDelAll();
            q.Handlers.MoveAdd();
        } else if (info.CurrentSelectTypeCode == config.SelectTypeCode.MultiOrg) {
            q.Handlers.MoveDelAll();
            q.Handlers.MoveAddAll();
        }
        window.setTimeout(q.Acts.ViewFirstSelectTreeMember, 1);
    }
    q.Handlers.TreeMemberSelecter_DblClick = function () {
        if (info.CurrentSelectTypeCode == config.SelectTypeCode.MultiPeople) {
            q.Handlers.MoveAdd();
        } else {
            window.setTimeout(q.Handlers.ButtonOK_Onclick, 10);
        }
    }
    q.Handlers.OrganizeTree_OnDblClicked = function (tree) {
        //是否为限制树节点
        if (tree && info.HaveOrganizationLimit && info.OrganizeTree.AvailTree[tree.ID] == null) return;
        //否则继续
        if (info.CurrentSelectTypeCode == config.SelectTypeCode.SingleOrg) {
            window.setTimeout(q.Handlers.ButtonOK_Onclick, 10);
        }
    }
    q.Handlers.SelectedMemberSelecter_Click = function () {
        window.setTimeout(q.Acts.ViewFirstSelectMember, 1);
    }
    var AttachEvent = q.AttachEvent = function () {
        info.OrganizeTree.OnClicked.push(q.Handlers.OrganizeTree_OnClicked);
        info.OrganizeTree.OnDblClicked.push(q.Handlers.OrganizeTree_OnDblClicked);
        with (q.Nodes) {
            $vs.addHandler(TreeMemberSelecterRemoveButton, dom.Events.onclick, q.Handlers.TreeMemberSelecterRemove);
            $vs.addHandler(TreeMemberSelecter, dom.Events.onclick, q.Handlers.TreeMemberSelecter_Click);
            $vs.addHandler(TreeMemberSelecter, dom.Events.ondblclick, q.Handlers.TreeMemberSelecter_DblClick);
            $vs.addHandler(SelectedMemberSelecter, dom.Events.onclick, q.Handlers.SelectedMemberSelecter_Click);
            $vs.addHandler(MoveAdd, "click", q.Handlers.MoveAdd);
            $vs.addHandler(MoveDel, "click", q.Handlers.MoveDel);
            $vs.addHandler(MoveAddAll, "click", q.Handlers.MoveAddAll);
            $vs.addHandler(MoveDelAll, "click", q.Handlers.MoveDelAll);
            $vs.addHandler(ButtonOK, $vs.dom.Events.onclick, q.Handlers.ButtonOK_Onclick);
            $vs.addHandler(ButtonCancel, $vs.dom.Events.onclick, q.Handlers.ButtonCancel_Onclick);
        }
    }
}
$vs.initType(eastcomClass);

eastcomClass.$new = function (dataProvider, idContainer, nameContainer, selectTypeCode, needReload, organizationIDLimit, context) {
    ///<summary>实例化窗体</summary>
    ///<param name="idContainer">结果ID存储容器ID</param>
    ///<param name="nameContainer">结果Name存储容器ID</param>
    ///<param name="selectTypeCode">选择方式的标识值</param>
    ///<param name="needReload">用户选择完毕后是否需要刷新整个页面</param>
    ///<param name="organizationIDLimit">指定组织的选择范围</param>
    ///<param name="context">请求标识,用户区分不同按钮的查询请求</param>
    ///<returns type="eastcom.OrganizeTreeViewWindow.Type"></returns>
    return this.New.apply(this, arguments);
}

/// <reference path="eastcom.OrganizeTreeViewWindow.js" />

eastcom.OrganizeTreeViewWindow.Open = function (dataProvider, sender, idContainerID, nameContainerID, selectTypeCode, needReload, organizationIDLimit, context) {
    var win = sender.OrganizeTreeViewWindow;
    if (!win) {
        var idContainer = $vs.doc.GetNode(idContainerID);
        var nameContainer = null;
        if (!Object.isNullOrEmpty(nameContainerID)) nameContainer = $vs.doc.GetNode(nameContainerID);
        win = sender.OrganizeTreeViewWindow = eastcom.OrganizeTreeViewWindow.$new(
            dataProvider
            , idContainer, nameContainer, selectTypeCode
            , needReload, organizationIDLimit, context);
    }
    win.ResetSelected();
    win.Show();
    //    window.setTimeout(function(){
    //        $vs.doc.GetDiv("v").value = win.Nodes.MainCase.outerHTML;
    //        //$vs.doc.GetDiv("vo").innerHTML = win.Nodes.MainCase.outerHTML;
    //    },1000);
}
eastcom.OrganizeTreeViewWindow.FillList = function (dataIndexer, nameContainer) {
    if ($vs.designMode) nameContainer = $vs.dom.Select;
    var dataArr = [];
    for (var id in dataIndexer) {
        dataArr.push(dataIndexer[id]);
    }
    //    $vs.parser.view(dataArr);
    //    $vs.parser.view(dataArr[0]);
    var data;
    var nodeName = nameContainer.nodeName.toLowerCase();
    if (nodeName == "select") {
        var selecter = nameContainer;
        selecter.options.length = 0;
        for (i = 0, len = dataArr.length; i < len; i++) {
            data = dataArr[i];
            if ($vs.designMode) data = { ID: "", Name: "" };
            var opt = $vs.dom.NewOption(data.Name, data.ID);
            opt.Data = data;
            selecter.appendChild(opt);
        }
    } else if (nodeName == "input") {
        var nameStringArr = [];
        for (i = 0, len = dataArr.length; i < len; i++) {
            data = dataArr[i];
            if ($vs.designMode) data = { ID: "", Name: "" };
            nameStringArr.push(data.Name);
        }
        nameContainer.value = nameStringArr.join(",");
    } else {
        nameContainer.innerHTML = "";
        for (i = 0, len = dataArr.length; i < len; i++) {
            data = dataArr[i];
            if ($vs.designMode) data = { ID: "", Name: "" };
            var span = $vs.dom.NewALink(null, null, data.Name, true);
            nameContainer.appendChild(opt);
        }
    }
}
eastcom.OrganizeTreeViewWindow.LoadPeopleNameAsyn = function (dataProvider, idContainerID, nameContainerID) {
    var idContainer = $vs.doc.GetNode(idContainerID);
    var nameContainer = $vs.doc.GetNode(nameContainerID);
    //window.setTimeout(function(){
    dataProvider.NeedSelectedPeoples(idContainer.value, eastcom.OrganizeTreeViewWindow.FillList, nameContainer)
    //},$vs.timerStep.NextStep());
}
eastcom.OrganizeTreeViewWindow.LoadOrganizationNameAsyn = function (dataProvider, idContainerID, nameContainerID) {
    var idContainer = $vs.doc.GetNode(idContainerID);
    var nameContainer = $vs.doc.GetNode(nameContainerID);
    //window.setTimeout(function(){
    dataProvider.NeedSelectedOrganizations(idContainer.value, eastcom.OrganizeTreeViewWindow.FillList, nameContainer)
    //},$vs.timerStep.NextStep());
}
/// <reference path="vs_common.js" />
/// <reference path="vs_window.js" />
/// <reference path="vs.Validater.js" />

Class = eastcom.QueryPanel = function () {
    with ($vs) {
        var q = inherit(this, arguments, vs.Window);
        if (!String) q = vs.Window.Q;

        var Me = this;
        q.Nodes.ListView = dom.Div;
        q.Nodes.ButtonSplit = dom.HR;   //最终操作按钮行
        q.Nodes.ButtonLine = dom.Div;   //最终操作按钮行
        q.Nodes.ToQueryButton = dom.Button; //确认查询按钮
        q.Nodes.CancelQueryButton = dom.Button; //取消查询按钮
        q.Nodes.WhereExpressionField = dom.Input;   //用来记录最终查询表达式的隐藏控件

        q.Nodes.QueryLines = [];
        q.Nodes.AndActs = [];   //并且and，或or
        q.Nodes.ColumnNameSelects = []; //列名
        q.Nodes.BoolActs = [];  //大于，等于，。。。
        q.Nodes.SelectValueInputs = [];   //布尔值下拉框
        q.Nodes.ValueInputs = [];   //输入值

        q.Info.QueryColumnDataDemo = { Field: "", Title: "", Type: "" };
        q.Enums.ColumnType = { Number: "Number", String: "String", DateTime: "DateTime", Boolean: "Boolean", Guid: "Guid" }
        q.Config.BoolActIsNull = "(isnull(convert(nvarchar(40),{0}) + '*','') = isnull(convert(nvarchar(40),{0}) + '#',''))";
        q.Config.BoolActIsNotNull = "(isnull(convert(nvarchar(40),{0}) + '*','') != isnull(convert(nvarchar(40),{0}) + '#',''))";
        q.Config.BoolActIsNullString = "({0} = '' or isnull(convert(nvarchar(40),{0}) + '*','') = isnull(convert(nvarchar(40),{0}) + '#',''))";
        q.Config.BoolActIsNotNullString = "({0} <> '' and isnull(convert(nvarchar(40),{0}) + '*','') != isnull(convert(nvarchar(40),{0}) + '#',''))";
        q.Config.BoolActerDemo = { Name: "大于", Tag: ">", NumberSQL: "{0} > {1}", StringSQL: "{0} > '{1}'" };
        q.Config.BoolActerList = [
        { Name: "包含", Tag: "like", DateTimeSQL: "CONVERT(varchar,{0},120) like '%{1}%'", NumberSQL: "Convert(nvarchar(200),{0}) like '%{1}%'", StringSQL: "{0} like '%{1}%'" },
        { Name: "左包含", Tag: "like", DateTimeSQL: "CONVERT(varchar,{0},120) like '{1}%'", NumberSQL: "Convert(nvarchar(200),{0}) like '{1}%'", StringSQL: "{0} like '{1}%'" },
        { Name: "右包含", Tag: "like", DateTimeSQL: "CONVERT(varchar,{0},120) like '%{1}'", NumberSQL: "Convert(nvarchar(200),{0}) like '%{1}'", StringSQL: "{0} like '%{1}'" },
        { Name: "不包含", Tag: "not like %%", DateTimeSQL: "CONVERT(varchar,{0},120) not like '%{1}%'", NumberSQL: "Convert(nvarchar(200),{0}) not like '%{1}%'", StringSQL: "{0} not like '%{1}%'" },
        { Name: "等于", Tag: "=", DateTimeSQL: "CONVERT(varchar,{0},120) like '%{1}%'", NumberSQL: "{0} = {1}", StringSQL: "{0} = '{1}'" },
        { Name: "大于", Tag: ">", DateTimeSQL: "CONVERT(varchar,{0},120) > '{1}'", NumberSQL: "{0} > {1}", StringSQL: "{0} > '{1}'" },
        { Name: "小于", Tag: "<", DateTimeSQL: "CONVERT(varchar,{0},120) < '{1}'", NumberSQL: "{0} < {1}", StringSQL: "{0} < '{1}'" },
        { Name: "大于等于", Tag: ">=", DateTimeSQL: "CONVERT(varchar,{0},120) >= '{1}'", NumberSQL: "{0} >= {1}", StringSQL: "{0} >= '{1}'" },
        { Name: "小于等于", Tag: "<=", DateTimeSQL: "CONVERT(varchar,{0},120) <= '{1}'", NumberSQL: "{0} <= {1}", StringSQL: "{0} <= '{1}'" },
        { Name: "不等于", Tag: "<>", DateTimeSQL: "CONVERT(varchar,{0},120) not like '%{1}%'", NumberSQL: "{0} <> {1}", StringSQL: "{0} <> '{1}'" },
        { Name: "始于", Tag: "like -%", DateTimeSQL: "CONVERT(varchar,{0},120) like '{1}%'", DateTimeSQL: "", NumberSQL: "Convert(nvarchar(200),{0}) like '{1}%'", StringSQL: "{0} like '{1}%'" },
        { Name: "不始于", Tag: "not like -%", DateTimeSQL: "CONVERT(varchar,{0},120) not like '{1}%'", NumberSQL: "Convert(nvarchar(200),{0}) not like '{1}%'", StringSQL: "{0} not like '{1}%'" },
        { Name: "结束于", Tag: "like %-", DateTimeSQL: "CONVERT(varchar,{0},120) like '%{1}'", NumberSQL: "Convert(nvarchar(200),{0}) like '%{1}'", StringSQL: "{0} like '%{1}'" },
        { Name: "不结束于", Tag: "not like %-", DateTimeSQL: "CONVERT(varchar,{0},120) not like '%{1}'", NumberSQL: "Convert(nvarchar(200),{0}) not like '%{1}'", StringSQL: "{0} not like '%{1}'" },
        { Name: "存在于", Tag: "in", DateTimeSQL: "CONVERT(varchar,{0},120) in ('{1}')", NumberSQL: "{0} in ({1})", StringSQL: "{0} in ('{1}')" },
        { Name: "等于空值", Tag: "isnull", DateTimeSQL: "{0} IS NULL", NumberSQL: q.Config.BoolActIsNull, StringSQL: q.Config.BoolActIsNullString },
        { Name: "不等于空值", Tag: "isnull", DateTimeSQL: "{0} IS NOT NULL", NumberSQL: q.Config.BoolActIsNotNull, StringSQL: q.Config.BoolActIsNotNullString }
    ];

        q.Config.AndActSelectGroup = [{ Name: "", Value: "" }, { Name: "并且/and", Value: "and" }, { Name: "或者/or", Value: "or"}];
        q.Config.BoolSelectGroup = [{ Name: "是", Value: 1 }, { Name: "否", Value: 0}];
        q.Config.QueryLineCount = 5;
        q.Info.QueryColumns = []
        q.Demos.LineGroup = {
            QueryLine: dom.Div,
            AndSelecter: dom.Select,
            ColumnNameSelecter: dom.Select,
            ActerSelect: dom.Select,
            ValueInput: dom.Input,
            SelectValueInput: dom.Select,
            Validater: vs.Validater.Demo
        }


        q.Acts.NewAndActSelecter = function () {
            with ($vs) {
                ///<summary>生成"并且"，"或者"选择下拉框</summary>
                ///<returns type="$vs.dom.Select"></returns>
                var selecter = dom.NewSelect(false);
                var group = q.Config.AndActSelectGroup;
                for (var i = 0, count = group.length; i < count; i++) {
                    var option = dom.NewOption(group[i].Name, group[i].Value);
                    selecter.appendChild(option);
                }
                return selecter;
            }
        }
        q.Acts.NewBoolSelecter = function () {
            with ($vs) {
                ///<summary>生成布尔值选择下拉框</summary>
                var selecter = dom.NewSelect(false);
                var group = q.Config.BoolSelectGroup;
                for (var i = 0, count = group.length; i < count; i++) {
                    var option = dom.NewOption(group[i].Name, group[i].Value);
                    selecter.appendChild(option);
                }
                return selecter;
            }
        }
        q.Acts.NewColumnNameSelecter = function () {
            with ($vs) {
                ///<summary>生成列名选择下拉框</summary>
                var selecter = dom.NewSelect(false);
                var group = q.Info.QueryColumns;
                for (var i = 0, count = group.length; i < count; i++) {
                    var column = group[i];
                    if (!String) column = q.Info.QueryColumnDataDemo;
                    var option = dom.NewOption(column.Title, column.Field);
                    option.Column = column;
                    selecter.appendChild(option);
                }
                return selecter;
            }
        }
        q.Acts.NewBoolActSelecter = function () {
            with ($vs) {
                ///<summary>生成判断操作如大于，小于等的下拉框</summary>
                var selecter = dom.NewSelect(false);
                var group = q.Config.BoolActerList;
                for (var i = 0, count = group.length; i < count; i++) {
                    var acter = group[i];
                    if (!String) acter = q.Config.BoolActerDemo;
                    var option = dom.NewOption(acter.Name, acter.Tag);
                    option.Acter = acter;
                    selecter.appendChild(option);
                }
                return selecter;
            }
        }
        q.Acts.GetSqlOfType = function (acter, column, value) {
            with (q.Enums) {
                ///<summary>依据列信息，操作信息生成一段判断SQL</summary>
                if (!String) acter = q.Config.BoolActerDemo;
                if (!String) column = q.Info.QueryColumnDataDemo;
                var sql;
                switch (column.Type) {
                    case ColumnType.Number:
                    case ColumnType.Boolean:
                        sql = (Object.isNullOrEmpty(value) && acter.Tag != "isnull") ? "" : acter.NumberSQL;
                        break;
                    case ColumnType.DateTime:
                        sql = (Object.isNullOrEmpty(value) && acter.Tag != "isnull") ? "" : acter.DateTimeSQL;
                        break;
                    case ColumnType.String:
                    case ColumnType.Guid:
                        sql = acter.StringSQL;
                        break;
                }
                var targetValue = (acter.Tag == "in") ? value.replace(/'/g, "''").replace(/\|/g, "','") : value.replace(/'/g, "''");
                if (!Object.isNullOrEmpty(sql)) sql = String.format(sql, column.Field, targetValue);
                return sql;
            }
        }
        q.Acts.GetSql = function () {
            var queryLineCount = q.Config.QueryLineCount;
            var whereExpression = "";
            var value;
            for (var i = 0; i < queryLineCount; i++) {
                var line = q.Nodes.QueryLines[i];
                var group = line.Group;
                if (!String) group = q.Demos.LineGroup;
                if (group.ColumnNameSelecter.disabled) continue;
                value = "";
                if ((isShow && group.ValueInput.IsSingleLine == true) || (!isShow && group.ValueInput.IsSingleLine != true)) continue;
                if (group.ValueInput.style.display != "none") value = group.ValueInput.value;
                if (group.SelectValueInput.style.display != "none") value = group.SelectValueInput.value;
                var sqlPart = q.Acts.GetSqlOfType(q.Config.BoolActerList[group.ActerSelect.selectedIndex],
                    q.Info.QueryColumns[group.ColumnNameSelecter.selectedIndex], value);
                if (Object.isNullOrEmpty(sqlPart)) continue;
                whereExpression += " " + group.AndSelecter.value + " "
                + sqlPart;
            }
            return whereExpression;
        }

        Me.Init = q.Acts.Load = function (queryColumns, toQueryButton, whereExpressionField) {
            with ($vs) {
                ///<summary>初始化窗体，加载基本的控件及数据</summary>
                ///<param name="queryColumns">查询列对象</param>
                ///<param name="toQueryButton">提交提交查询的按钮</param>
                ///<returns type="eastcom.QueryPanel.Type"></returns>
                q.Nodes.ListView = dom.NewDiv("");
                toQueryButton.parentNode.insertBefore(q.Nodes.ListView, toQueryButton);
                q.Load(q.Nodes.ListView, false, 550, 300);
                q.Info.QueryColumns = queryColumns;
                q.Nodes.ToQueryButton = toQueryButton;
                q.Nodes.ButtonLine = dom.NewDiv("");
                q.Nodes.WhereExpressionField = whereExpressionField;
                q.SetTitle("通用查询");
                q.Acts.SetMaxGoEnable(false);
                q.Acts.SetMinGoEnable(false);
                q.SetCenterStartPosition();
                //变关闭为隐藏
                $vs.removeHandler(q.Nodes.CloseViewGo, "click", q.Close);
                $vs.addHandler(q.Nodes.CloseViewGo, "click", q.ToHide);
                //取消双击标题行窗口最大化
                $vs.removeHandler(q.Nodes.TitleView, "dblclick", q.Handlers.WindowMaxChg)
                $vs.addHandler(q.Nodes.MainCase, dom.Events.onkeydown, q.Handlers.ToQueryEnterKey)
            }
        }

        q.Acts.BindGroup = function (group) {
            for (var key in group) {
                if (group[key]) group[key].Group = group;
            }
        }
        q.Info.SingleLineGroup = null;
        Me.CreateBasicLine = q.Acts.CreateBasicLine = function () {

        }
        Me.CreateLine = q.Acts.CreateLine = function (line, isFirstLine, btnSumbit, hiddens) {
            var andSelecter = q.Acts.NewAndActSelecter();
            var columnNameSelecter = q.Acts.NewColumnNameSelecter();
            var acterSelect = q.Acts.NewBoolActSelecter();
            var valueInput = dom.NewTextInput("", "");
            var selectValueInput = q.Acts.NewBoolSelecter();
            //载入
            if (!String) andSelecter = dom.Select;
            if (isFirstLine) andSelecter.style.visibility = "hidden";
            selectValueInput.style.display = "none";
            with (q.Nodes) {
                with (line) {
                    appendChild(andSelecter);
                    appendChild(columnNameSelecter);
                    appendChild(acterSelect);
                    appendChild(valueInput);
                    appendChild(selectValueInput);
                }
                QueryLines.push(line);
                AndActs.push(andSelecter);
                ColumnNameSelects.push(columnNameSelecter);
                BoolActs.push(acterSelect);
                ValueInputs.push(valueInput);
                SelectValueInputs.push(selectValueInput);
            }
            var validater = vs.Validater.$new(valueInput);
            //编组并绑定
            var group = {
                QueryLine: line,
                AndSelecter: andSelecter,
                ColumnNameSelecter: columnNameSelecter,
                ActerSelect: acterSelect,
                ValueInput: valueInput,
                SelectValueInput: selectValueInput,
                Validater: validater
            };
            q.Acts.BindGroup(group);
            if (btnSumbit) {
                group.Hiddens = hiddens;
                btnSumbit.onclick = function (e) {
                    var g = q.Info.SingleLineGroup;
                    g.Hiddens[0].value = g.ColumnNameSelecter.value;
                    g.Hiddens[1].value = g.ActerSelect.value;
                    g.Hiddens[2].value = (g.SelectValueInput.style.display == "none") ? g.ValueInput.value : g.SelectValueInput.value;
                    q.Handlers.ToQuery.apply(q.Nodes.ToQueryButton, [e]); return false;
                }
                valueInput.IsSingleLine = true;
                valueInput.BtnSubmit = btnSumbit;
                $vs.addHandler(valueInput, $vs.dom.Events.onkeypress, function (e) {
                    if (e.keyCode == 13) { this.BtnSubmit.click(); return false; }
                });
                if (hiddens[0].value != "") columnNameSelecter.value = hiddens[0].value;
                if (hiddens[1].value != "") acterSelect.value = hiddens[1].value;
                valueInput.value = hiddens[2].value;
                if (hiddens[2].value != "") selectValueInput.value = hiddens[2].value;
                andSelecter.style.display = "none";
                q.Info.SingleLineGroup = group;
                //columnNameSelecter.onchange = function () { hiddens[0].value = this.value; }
            }
            q.Config.QueryLineCount += 1;
        }
        Me.CreatePanel = q.Acts.CreatePanel = function (queryLineCount) {
            with ($vs) {
                ///<summary>初始化操作面板，生成操作元素</summary>
                ///<param name="queryLineCount">查询行数</param>
                q.Config.QueryLineCount = 0;

                for (var i = 0; i < queryLineCount; i++) {
                    var line = dom.NewDiv("");
                    q.Nodes.ListView.appendChild(line);
                    q.Acts.CreateLine(line, (i == 0));
                }
                //按钮行 
                with (q.Nodes) {
                    ButtonSplit = dom.NewHR();
                    ButtonLine = dom.NewDiv();
                    CancelQueryButton = dom.NewSubmitInputWithValue("取消");
                    ListView.appendChild(ButtonSplit);
                    ListView.appendChild(ButtonLine);
                    //var button = dom.NewButton();
                    ButtonLine.appendChild(ToQueryButton);
                    ToQueryButton.style.display = "inline";
                    ButtonLine.appendChild(CancelQueryButton);
                    //ToQueryButton(CancelQueryButton);
                }
                //绑定样式
                q.BindSelfSkin("eastcom_QueryPanel");
                q.Acts.ClearValues();
                q.Acts.BindHandler();
            }
        }
        q.Acts.SetLineActived = function (group, disabled) {
            if (!String) group = q.Demos.LineGroup;
            for (var key in group) {
                if (key == "AndSelecter" || key == "QueryLine") continue;
                var input = group[key];
                input.disabled = disabled;
            }
        }
        q.Acts.ClearValues = function () {
            ///<summary>还原成初始状态</summary>
            var queryLineCount = q.Config.QueryLineCount;
            for (var i = 0; i < queryLineCount; i++) {
                var line = q.Nodes.QueryLines[i];
                var group = line.Group;
                if (!String) group = q.Demos.LineGroup;
                group.AndSelecter.value = "";
                q.Acts.SetLineActived(group, i > 0);
            }
        }
        var isShow = false;
        Me.ShowDialog = q.Acts.ShowDialog = function () {
            q.Show();
            isShow = true;
        }
        q.Handlers.LineHeaderChange = function (e) {
            var select = this; if (!String) select = $vs.dom.Select;
            if (select.value == "") {
                q.Acts.SetLineActived(select.Group, true);
            } else {
                q.Acts.SetLineActived(select.Group, false);
            }
        }
        q.Handlers.ColumnNameChange = function (e) {
            var select = this; if (!String) select = $vs.dom.Select;
            if (select.selectedIndex < 0) return;
            var column = q.Info.QueryColumns[select.selectedIndex]; if (!String) column = q.Info.QueryColumnDataDemo;
            group = select.Group; if (!String) group = q.Demos.LineGroup;
            //布尔类型的值限为选择框，并且判断方式限两种：等于，等于null
            if (column.Type == q.Enums.ColumnType.Boolean) {
                group.ValueInput.style.display = "none";
                group.SelectValueInput.style.display = "inline";
                group.ActerSelect.value = "=";
            } else {
                group.ValueInput.style.display = "inline";
                group.SelectValueInput.style.display = "none";
            }
            //绑定值的验证类型
            var input = group.ValueInput;
            if (input.style.display == "none") return;
            var validater = group.Validater;
            validater.ClearBinder();
            var types = q.Enums.ColumnType;
            switch (column.Type) {
                case types.Number:
                    validater.BindNumber();
                    break;
                case types.DateTime:
                    //validater.BindDateTime();
                    break;
                default:
                    //validater.BindTrim();
                    break;
            }
        }
        q.Handlers.BoolActChange = function (e) {
            var select = this; if (!String) select = $vs.dom.Select;
            var acter = q.Config.BoolActerList[select.selectedIndex]; if (!String) acter = q.Config.BoolActerDemo;
            group = select.Group; if (!String) group = q.Demos.LineGroup;
            var column = q.Info.QueryColumns[group.ColumnNameSelecter.selectedIndex]; if (!String) column = q.Info.QueryColumnDataDemo;
            //布尔类型的值限为选择框，并且判断方式限两种：等于，等于null
            if (column.Type == q.Enums.ColumnType.Boolean && acter.Tag != "＝" && acter.Tag != "isnull") {
                window.alert(String.format("对于 {0} 这一列只能做 等于 或者 等于null 的判断！", column.Title));
                select.value = "=";
            }
            if (select.value == "isnull") {
                group.ValueInput.disabled = true;
                group.SelectValueInput.disabled = true;
            } else {
                group.ValueInput.disabled = false;
                group.SelectValueInput.disabled = false;
            }
        }
        q.Handlers.ToQueryServer = null;
        q.Handlers.ToQuery = function (e) {
            q.Nodes.WhereExpressionField.value = q.Acts.GetSql();
            q.Handlers.ToQueryServer.apply(this, [e]);
        }
        q.Handlers.ToQueryEnterKey = function (e) {
            if (e.keyCode == 13) {
                q.Nodes.ToQueryButton.click();
                e.returnValue = false;
                e.cancelBubble = true;
            }
        }
        q.Acts.ToHide = function () {
            isShow = false;
            q.Hide();
            return false;
        }
        q.Acts.BindHandler = function () {
            var i = 0, count = 0, group;
            //第一列，选择and | or
            for (i = 0, group = q.Nodes.AndActs, count = group.length; i < count; i++) {
                $vs.addHandler(group[i], $vs.dom.Events.onchange, q.Handlers.LineHeaderChange);
            }
            //第二列，选择列名
            for (i = 0, group = q.Nodes.ColumnNameSelects, count = group.length; i < count; i++) {
                $vs.addHandler(group[i], $vs.dom.Events.onchange, q.Handlers.ColumnNameChange);
            }
            if (q.Nodes.ColumnNameSelects.length > 0) q.Handlers.ColumnNameChange.apply(q.Nodes.ColumnNameSelects[0], []);
            //第三列，选择判断方式
            for (i = 0, group = q.Nodes.BoolActs, count = group.length; i < count; i++) {
                $vs.addHandler(group[i], $vs.dom.Events.onchange, q.Handlers.BoolActChange);
            }
            //暂时移开ToQuery上原来的click事件
            q.Handlers.ToQueryServer = q.Nodes.ToQueryButton.onclick;
            q.Nodes.ToQueryButton.onclick = null;
            //再重新绑定新的
            $vs.addHandler(q.Nodes.ToQueryButton, $vs.dom.Events.onclick, q.Handlers.ToQuery);
            //绑定取消按钮
            $vs.addHandler(q.Nodes.CancelQueryButton, $vs.dom.Events.onclick, q.Acts.ToHide);
        }
    }
}
$vs.initType(Class);

Class.$new = function (queryColumns, toQueryButton, whereExpressionField) {
    ///<param name="queryColumns">查询列对象</param>
    ///<param name="toQueryButton">提交查询的按钮</param>
    ///<param name="whereExpressionField">提交查询SQL的隐藏域</param>
    ///<returns type="eastcom.QueryPanel.Type"></returns>
    return this.New.apply(this, arguments);
}
/// <reference path="eastcom.QueryPanel.js" />

eastcom.QueryPanel.Init = function (queryColumnsFieldID, queryButtonID, panelID, whereExpressionFieldID) {
    with ($vs) {
        ///<summary>打开查询窗</summary>
        ///<param name="queryColumnsFieldID">查询列对象的JSON字符串值容器</param>
        ///<param name="queryButtonID">确认查询的按钮</param>
        ///<param name="whereExpressionField">提交查询SQL的隐藏域</param>
        ///<param name="panelID">打开查询所在的页面容器</param>
        var queryColumnsField = doc.GetInput(queryColumnsFieldID);
        var queryColumns = eval("(" + queryColumnsField.value + ")");
        var queryButton = doc.GetNode(queryButtonID);
        var panel = doc.GetNode(panelID);
        var whereExpressionField = doc.GetHiddenInput(whereExpressionFieldID);
        var queryPanel = panel.QueryPanel;
        if (!queryPanel) {
            //初始化查询窗
            queryPanel = panel.QueryPanel = eastcom.QueryPanel.$new(queryColumns, queryButton, whereExpressionField);
            queryPanel.CreatePanel(8);
        }
    } 
}


eastcom.QueryPanel.FillLine = function (panelID, lineID, btnSubmitID, hiddens) {
    var panel = $vs.doc.GetNode(panelID);
    var queryPanel = panel.QueryPanel;
    //显示查询窗体
    if (queryPanel) queryPanel.CreateLine(lineID, true, btnSubmitID, hiddens);
}

eastcom.QueryPanel.Open = function (panelID) {
    var panel = $vs.doc.GetNode(panelID);
    var queryPanel = panel.QueryPanel;
    //显示查询窗体
    if (queryPanel) queryPanel.ShowDialog();
}